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

If a number is enclosed in quotes, it's a ______. string string
What is the value of orderTotal? let merchTotal = 100;
let shippingCharge = 10;
let orderTotal = merchTotal + shippingCharge;
110 110
In a single statement, declare the variable numberAsString and assign the number 3 to it as a string. let numberAsString = "3"; letnumberAsString=•3•;
Assign to the variable caseQty, which has already been declared, the value 144. caseQty = 144; caseQty=144;
In a single statement declare a variable and assign a number to it. Make up the variable name and the number. let x = 0; let.*=[-]?(?:[.]\d+|\d+(?:[.]\d*)?);
In a single statement declare a variable and assign to it the sum of 2 other variables. Make up the variable names. let total = price + tax; let.*=.*\+.*;
Assign the sum of 2 numbers to a variable, which hasn't been declared beforehand. Make up the variable name and the numbers. let total = 2 + 2; let.*=[-]?(?:[.]\d+|\d+(?:[.]\d*)?)\+[-]?(?:[.]\d+|\d+(?:[.]\d*)?);
In one statement declare a variable. In a second statement assign it the sum of 2 numbers. Make up the variable name and the numbers. let x;
x = 2 + 2;
let(.*);[\r\n]\1=[-]?(?:[.]\d+|\d+(?:[.]\d*)?)\+[-]?(?:[.]\d+|\d+(?:[.]\d*)?);
  1. Replace the asterisks with two statements.
  2. In the first statement declare a variable and assign it a number.
  3. In the second statement code an alert, specifying the variable, not the number, as the message.
  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 3 in the book.
  1. Replace the asterisks with three statements.
  2. In the first statement declare a variable and assign it a number.
  3. In the second statement double the variable's value by adding the variable to itself.
  4. In the third statement display the variable's value in an alert, specifying the variable, not the number, as the message.
  5. Click the Result button (or, after revising, don't click, just wait).
  6. Wait a moment.
  7. If you've coded correctly, an alert will display the number.
  8. Dismiss the alert by clicking OK.
  9. For help with this code, see Chapter 3 in the book.