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

What are the opening and closing tags that enclose embedded JavaScript code? Don't separate them with a space. <script></script> [<]script[>][<]\/script[>]
What are the last 3 characters of a JavaScript file name? .js \.js
Write a link to the file my-scripts.js. Don't forget the closing tag. <script src="my-scripts.js"></script> <\/script>
If you follow my recommendation for placing embedded JavaScript code, what is the HTML tag that comes immediately after your JavaScript code? </body> [<]\/body[>]
What is an example of a name for an external JavaScript file? Make up the part before the dot. main.js [a-zA-Z][a-zA-Z0-9_-]*\.js
Write the opening tag that links to an external JavaScript file. Make up the part before the dot in the JavaScript file name. <script src="main.js"> [<]scriptsrc=•.*\.js•[>]
In three lines of code, embed an alert including the appropriate opening and closing embed tags. Make up the string in the alert. <script>
  alert("Hello world!");
</script>
[<]script[>][\r\n]alert\(•.*•\);[\r\n][<]/script[>]
Write a link to an external JavaScript file. Include the closing tag. Make up the part of the name before the dot. <script src="my-scripts.js"></script> [<]scriptsrc=•[a-zA-Z][a-zA-Z0-9_-]*\.js•[>][<]\/script[>]
  1. Click the HTML button.
  2. In the HTML panel, within script tags, embed an alert.
  3. Click the Result button (or, after revising, don't click, just wait).
  4. Wait a moment.
  5. If you've coded correctly, the alert will display.
  6. Dismiss the alert by clicking OK.
  7. For help with this code, see Chapter 17 in the book.
  1. Click the HTML button.
  2. I've created an external JavaScript file, https://assets.codepen.io/167179/link-practice.js In the HTML panel, link to the file. (Copy and paste the file name to save yourself effort.)
  3. The file contains a function, flatterUser(). Below your link statement, embed a line of JavaScript that calls the function.
  4. Click the Result button (or, after revising, don't click, just wait).
  5. Wait a moment.
  6. If you've coded correctly, a flattering alert will display.
  7. Dismiss the alert by clicking OK.
  8. For help with this code, see Chapter 17 in the book.