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

Enter the operators, in this order—for addition, subtraction, multiplication, and division. Don't type spaces between them. +-*/ \+-\*\/
What is the name of the arithmetic operator that gives you the remainder when one number is divided by another? (one word) modulus modulus
Type the modulus operator. %% %
What is the value of num? let num = 20 % 6; 2 2
Fill in the blank with the expression 100 multiplied by 200. let alrgeNum = ____________; 100 * 200 100\*200
Fill in the blank. The expression is 9 divided by the variable qty. let num = ___________; 9 / qty 9\/qty
Assign to the variable total the result of subtracting one variable from another variable. total has been declared beforehand. Make up the two variable names in the expression. total = num1 – num2; total=[a-z_$][a-zA-Z0-9_$]*-[a-z_$][a-zA-Z0-9_$]*;
Assign to a variable the remainder when one integer is divided by another. The variable hasn't been declared beforehand. Make up the variable name and the numbers. let leftOver = 10 % 3; let[a-z_$][a-zA-Z0-9_$]*=[-]?(?:[.]\d+|\d+(?:[.]\d*)?)%[-]?(?:[.]\d+|\d+(?:[.]\d*)?);
  1. Assign numbers to 2 variables that haven't been declared beforehand.
  2. Code an alert that displays the result of a math operation—any math operation—on the variables.
  3. Click the Result button (or, after revising, don't click, just wait).
  4. Wait a moment.
  5. If you've coded correctly, the result will display.
  6. Dismiss the alert by clicking OK.
  7. For help with this code, see Chapter 5 in the book.
  1. In a single statement, code an alert that displays the result of a math operation—any math operation—on 2 numbers.
  2. Click the Result button (or, after revising, don't click, just wait).
  3. Wait a moment.
  4. If you've coded correctly, the result of the math operation will display.
  5. Dismiss the alert by clicking OK.
  6. For help with this code, see Chapter 5 in the book.