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

Type the character used in a template literal to enclose a string. ` `
Assign a string to a variable using a template literal. Make up the variable name and the string. let text = `Hello World!`; let[a-z_$][a-zA-Z0-9_$]*=`.*`;
Rewrite this statement using a template literal. let aName = 'Alex "the Hammer" Brown'; let aName = `Alex "the Hammer" Brown`; letaName=`Alex•theHammer•Brown`;
Rewrite this statement using a template literal. let greeting = "Hi, " + username; let greeting = `Hi, ${username}`; letgreeting=`Hi,\${username}`;
Code an alert using a template literal that contains double quotation marks inside the string. Make up the string. alert(`Call me "Marco"`); alert\(`.*•.*•.*\);
Rewrite this statement using a template literal. let text = "Hello " + "World!"; let text = `Hello World!`; lettext=`HelloWorld!`;
Rewrite this statement using a template literal. let text = "The total is " + total; let text = `The total is ${total}`; lettext=`Thetotalis\${total}`;
Use a template literal to combine a string with the expression 2 * 3 . Put the string first. Assign the combination to a variable. Make up the name of the variable and the string. let text = `Product: ${2 * 3}`; let[a-z_$][a-zA-Z0-9_$]*=`.*\${2\*3}`;
  1. I've assigned a string to a variable. Add an additional statement: Using a template literal, combine a string literal with the variable in an alert.
  2. Click the Result button (or, after revising, don't click, just wait).
  3. Wait a moment.
  4. If you've coded correctly, the string will display in an alert.
  5. Dismiss the alert by clicking OK.
  6. For help with this code, see Chapter 9 in the book.
  1. Rewrite the statement using a template literal, breaking the three syllables into three separate lines.
  2. Code an alert using the variable.
  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 the string on three separate lines.
  6. Dismiss the alert by clicking OK.
  7. For help with this code, see Chapter 9 in the book.