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

The keyword for creating a constant is ______. const const
A constant can't be re-declared or _______. reassigned reassigned
If there's a possibility of reassignment, the keyword to use is ____ let let
Create a constant, players, and assign it 11. const players = 11; constplayers=11;
Create a string constant, name, assigning it your first name. Or make up the name. const name = "Mark"; constname=•.*•;
Create an integer constant. Make up the name and value. const players = 11; [a-z_$][a-zA-Z0-9_$]*=(0|-?[1-9][\d]*);
Define two integer constants on the same line. Make up the names of the contants and the integers. const start = 0, stop = 1; const[a-z_$][a-zA-Z0-9_$]*=(0|-?[1-9][\d]*),[a-z_$][a-zA-Z0-9_$]*=(0|-?[1-9][\d]*);
Declare a constant inside a function, assigning it a number. Code a statement that sends the value back to the calling code. Make everything up. function sendNum() {
  const num = -10;
  return num;
}
function[a-z_$][a-zA-Z0-9_$]*\(\){[\r\n]const([a-z_$][a-zA-Z0-9_$]*)=[-]?(?:[.]\d+|\d+(?:[.]\d*)?);[\r\n]return\1;[\r\n]}
  1. Declare two string constants.
  2. Concatenate them, assigning the combination to a third constant.
  3. Display the value of the third constant in an alert.
  4. Click the Result button (or, after revising, don't click, just wait).
  5. Wait a moment.
  6. If you've coded correctly, the value will display in an alert.
  7. Dismiss the alert by clicking OK.
  8. For help with this code, see Chapter 20 in the book.
  1. Assign a float to a constant.
  2. Multiply the constant by an integer, assigning the result to a variable.
  3. Display the value of the result in an alert.
  4. Click the Result button (or, after revising, don't click, just wait).
  5. Wait a moment.
  6. If you've coded correctly, an alert will display the number.
  7. Dismiss the alert by clicking OK.
  8. For help with this code, see Chapter 20 in the book.