JavaScript Simplified / Chapter 95 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 is the file extension of a module? .js \.js
Fill in the blank to make the three features available to other scripts and .js files. ______ { num, showNum, an Animal }; export export
Code the statement that exports two features of a module. Make up the names of the features. export { name, age }; export{[a-z_$][a-zA-Z0-9_$]*,[a-z_$][a-zA-Z0-9_$]*};
Rewrite the following code to correct it. export { computeInterest() }; export { computeInterest }; export{computeInterest};
A module file contains the following code. Export both features. const scores = [23, 11, 99];
function sendDate() {
  return new Date();
}
export { scores, sendDate }; export{scores,sendDate};
Code the opening tag for a script that imports from a module. <script type = "module"> (?<=<)scripttype=•module•>
Code the statement that imports two features from a module. The module is at "./mod.js". Make up the names of the features. import { scores, addScores } from "./mod.js"; import{[a-z_$][a-zA-Z0-9_$]*,[a-z_$][a-zA-Z0-9_$]*}from•\.\/mod\.js•;
Code the opening script tag and the statement to import a single feature. The module is at "./mod.js". Make up the name of the feature. <script type = "module">
import { scores } from "./mod.js";
(?<=<)scripttype=•module•>[\r\n]import{scores}from•\.\/mod\.js•;
  1. You're working inside the HTML panel. Replace the asterisks with a statement that imports num and showNum. You can copy and paste the location of the module: https://codepen.io/asmarterwaytolearn/pen/LYJbGza.js
  2. In the Result panel, click the See the number button.
  3. If you've coded correctly, an alert will display the number 12.
  4. Dismiss the alert by clicking OK.
  5. For help with this code, see Chapter 95 in the book.
  1. You're working inside the HTML panel. Code opening and closing script tags for importing from a module.
  2. Inside the script tags, import an array. The array's name is pets. You can copy and paste the location of the module: https://codepen.io/asmarterwaytolearn/pen/LYJbGza.js
  3. The array has three elements. Code an alert that displays one of the elements.
  4. Click the Result button (or, after revising, don't click, just wait).
  5. If you've coded correctly, an alert will display a pet.
  6. Dismiss the alert by clicking OK.
  7. For help with this code, see Chapter 95 in the book.