JavaScript Simplified / Chapter 77 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

Assign the integer 0 to the height property of the object whose identifier is line. line.height = 0; line\.height=0;
Get the value of the volume property of the object tank and assign it to the variable vol, which hasn't been declared beforehand. let vol = tank.volume; letvol=tank\.volume
Get the value of the golfHandicap property of the object frankenstein and assign it to the variable hCap, which hasn't been defined beforehand. let hCap = frankenstein.golfHandicap; lethCap=frankenstein\.golfHandicap;
Declare the name property of the object newSpecies, assigning it no value. newSpecies.name = ""; newSpecies\.name=••;
Assign a Boolean value to an object's property. Make up the object identifier and property name and choose the Boolean. candidate.pledge = false; [a-z_$][a-zA-Z0-9_$]*\.[a-z_$][a-zA-Z0-9_$]*=(true|false);
Display the value of an object's property in an alert. Make up everything. alert(mexico.area); alert\([a-z_$][a-zA-Z0-9_$]*\.[a-z_$][a-zA-Z0-9_$]*\);
Remove an object's property. Make up everything. delete judgeSmithfield.nickname; delete[a-z_$][a-zA-Z0-9_$]*\.[a-z_$][a-zA-Z0-9_$]*;
Code the first line of an if statement that checks whether an object has a particular property. Make up everything. if ("wins" in sanMarino) { if\(•[a-z_$][a-zA-Z0-9_$]*•in[a-z_$][a-zA-Z0-9_$]*\){
  1. Create an empty object.
  2. Assign the object a property with a value.
  3. Display the value of the property in an alert.
  4. Wait a moment.
  5. If you've coded correctly, an alert will display the property value.
  6. Dismiss the alert by clicking OK.
  7. For help with this code, see Chapter 77 in the book.
  1. Create an object with a single property.
  2. Check whether the object has a different property.
  3. If not, assign the object that property, with a value.
  4. Display the value of that property in an alert.
  5. Wait a moment.
  6. If you've coded correctly, an alert will display the value of the new property.
  7. Dismiss the alert by clicking OK.
  8. For help with this code, see Chapter 77 in the book.