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

Fill in the blank to append newNode to parentNode. parentNode._______ (newNode); appendChild appendChild
Fill in the blank to append newNode to parentNode. parentNode._____________; appendChild(newNode) appendChild\(newNode\)
In div1 replace oldP with newP . div1.replaceChild(newP, oldP); div1\.replaceChild\(newP,oldP\);
In citiesList remove thirdItem. citiesList.removeChild(thirdItem); citiesList\.removeChild\(thirdItem\);
In selectedDiv insert headingNew before heading1. selectedDiv.insertBefore(headingNew, heading1); selectedDiv\.insertBefore\(headingNew,heading1\);
A paragraph has been assigned to a variable, and some text has been assigned to a variable. Append the text to the paragraph. Make up the variable names. bioParagraph.appendChild(newText); [a-z_$][a-zA-Z0-9_$]*\.appendChild\([a-z_$][a-zA-Z0-9_$]*\);
A heading has been assigned to mainHead. The current text in the heading has been assigned to oldText. Replace oldText with text assigned to newText. mainHead.replaceChild(newText, oldText); mainHead\.replaceChild\(newText,oldText\);
A div has been assigned to theDiv. An image within the div has been assigned to oldImg. Insert an image assigned to newImg, before oldImg. theDiv.insertBefore(newImg, oldImg); theDiv\.insertBefore\(newImg,oldImg\);
  1. Click the HTML button to see my markup.
  2. Click the JS button.
  3. Below my JavaScript code, add some code to replace toBeReplaced with newP.
  4. Click the Result button (or, after revising, don't click, just wait).
  5. Wait a moment.
  6. If you've coded correctly, the last line of text in the Result panel will change to "Insurgents".
  7. Dismiss the alert by clicking OK.
  8. For help with this code, see Chapter 118 in the book.
  1. Click the HTML button to see my markup.
  2. Click the JS button.
  3. 10. I've coded some markup and three lines of JavaScript. Under my JavaScript code, add some code to insert newP before lastP.
  4. Click the Result button (or, after revising, don't click, just wait).
  5. Wait a moment.
  6. If you've coded correctly, "Evening" will be inserted before "Night".
  7. Dismiss the alert by clicking OK.
  8. For help with this code, see Chapter 118 in the book.