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

Code the first line of a method, calcTotal(), inside a constructor. this.calcTotal = function() { this\.calcTotal=function\(\){
Code the first line of a method, calcTotal(), in a prototype. The constructor's name is Order. Order.prototype.calcTotal = function() { Order\.prototype\.calcTotal=function\(\){
Code the first line of a method, showName(), inside a constructor. this.showName = function() { this\.showName=function\(\){
Code the first line of a method, showName() in a prototype. The constructor's name is Patient. Patient.prototype.showName = function() { Patient\.prototype\.showName=function\(\){
Code the first line of a statement that creates a single copy of a method for all objects created by a constructor. Make up the names. Planet.prototype.calcDensity = function() { [A-Z][a-zA-Z0-9_$]*\.prototype\.[a-z_$][a-zA-Z0-9_$]*=function\(\){
Code the first line of a statement that creates a single copy of a string property for all objects created by a constructor. Make up everything. Primate.prototype.stance = "upright"; [A-Z][a-zA-Z0-9_$]*\.prototype\.[a-z_$][a-zA-Z0-9_$]*=•.*•;
Code a statement that creates a single copy of an integer property for all objects created by a constructor. Make up everything. Primate.prototype.arms = 2; [A-Z][a-zA-Z0-9_$]*\.prototype\.[a-z_$][a-zA-Z0-9_$]*=(0|-?[1-9][\d]*);
Code a statement that overrides a prototype's integer property value. Make up everything. starfish.arms = 5; [a-z_$][a-zA-Z0-9_$]*\.[a-z_$][a-zA-Z0-9_$]*=(0|-?[1-9][\d]*);
  1. Click the HTML button to see my markup for an empty paragraph whose ID is "p1".
  2. Click the Result button to see the blank page.
  3. Click the JS button to see my code for a constructor.
  4. Create an object using the constructor.
  5. Create a prototype method for all of the constructor's objects that displays the sum of the properties in the paragraph whose ID is "p1".
  6. Call the method.
  7. If you've coded correctly, the sum of the properties will be displayed on the page.
  8. For help with this code, see Chapter 83 in the book.
  1. Click the HTML button to see my markup for an empty paragraph whose ID is "p1".
  2. Click the Result button to see the blank page.
  3. Click the JS button to see my code for a constructor.
  4. Create an object using the constructor.
  5. Create a prototype string property for all of the constructor's objects.
  6. Code a statement that displays the property value of the new object in the paragraph whose ID is "p1".
  7. If you've coded correctly, the property's value will display on the page.
  8. For help with this code, see Chapter 83 in the book.