JavaScript Simplified / Chapter 79 Exercises

  • Index of exercises
  • Email me

1

2

3

4

5

6

7

8

9

10

Congratulations. You've aced all the exercises for this chapter.


To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to CodePen.


Are you ready to rate JavaScript Simplified? on Amazon?


Rate it on Amazon.

0,1,2,3,4,5,6,7,8,9

0

0

0

0

A function that's part of an object definition is a _____. method method
A method is a _______ of an object. property property
Complete this first line for a method named calc. ________ function() { calc: calc:
Code the first line for a method named calc. calc: function() { calc:function\(\){
Code the first line of a method definition. Make up the name of the method. capitalize: function() { [a-z_$][a-zA-Z0-9_$]*:function\(\){
Call a method, assigning the returned value to a variable. Make up all the names. let result = planet.distance(); let[a-z_$][a-zA-Z0-9_$]*=[a-z_$][a-zA-Z0-9_$]*\.[a-z_$][a-zA-Z0-9_$]*\(\);
Instead of using the object's identifier when referring to a property, a method uses the keyword _____. this this
Code a method definition. The method displays a property of the object in an alert. Make up everything. display: function() {
  alert(this.color);
}
[a-z_$][a-zA-Z0-9_$]*:function\(\){[\r\n]alert\(this\.[a-z_$][a-zA-Z0-9_$]*\);[\r\n]}
  1. Define an object that has two integer properties and a method. The method returns the sum of the two properties.
  2. Code an alert that calls the method and displays the returned value.
  3. Wait a moment.
  4. If you've coded correctly, an alert will display the value.
  5. Dismiss the alert by clicking OK.
  6. For help with this code, see Chapter 79 in the book.
  1. Define an object with one integer property and a method with one integer parameter. The method multiplies the property by the parameter.
  2. Code an alert that calls the method, passing an integer argument, and displays the returned value.
  3. Wait a moment.
  4. If you've coded correctly, an alert will display the value.
  5. Dismiss the alert by clicking OK.
  6. For help with this code, see Chapter 79 in the book.