JavaScript Simplified / Chapter 13 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 comparison operator is greater than? > >
What is the comparison operator is less than or equivalent to? <= <=
Code the first line of an if statement that tests whether num1 is greater than num2. if (num1 > num2) { if\(num1>num2\){
Code the first line of an if statement that tests whether num1 is greater than or equivalent to num2. if (num1 >= num2) { if\(num1>=num2\){
Code the first line of an if statement that tests whether one variable is not equivalent to another. Make up the variable names. if (firstName !== nickname) { if\([a-z_$][a-zA-Z0-9_$]*!==[a-z_$][a-zA-Z0-9_$]*\){
Code the first line of an if statement that tests whether a variable's value isn't equivalent to a particular string. Make up the variable name and the string. if (gender !== "female") { if\([a-z_$][a-zA-Z0-9_$]*!==•.*•\){
Code the first line of an if statement that tests whether a variable's value is less than a particular number. Make up the variable name and the number. if (num < 1) { if\([a-z_$][a-zA-Z0-9_$]*<[-]?(?:[.]\d+|\d+(?:[.]\d*)?)\){
Code the first line of an if statement that tests whether a string is not equivalent to a particular variable's value. Make up the string and the variable name. if ("Mexico" !== countryOfOrigin) { if\(•[a-z_$][a-zA-Z0-9_$]*•!==.*\){
  1. Code an if statement that tests whether a number is not equivalent to a different number.
  2. If the condition is true (it will to be), display a congratulations alert.
  3. Click the Result button (or, after revising, don't click, just wait).
  4. Wait a moment.
  5. If you've coded correctly, your congratulations alert will display.
  6. Dismiss the alert by clicking OK.
  7. For help with this code, see Chapter 13 in the book.
  1. Code an if statement that tests whether 0 is less than 1.
  2. If the condition is true (it will be), display an alert that says "Less than".
  3. Click the Result button (or, after revising, don't click, just wait).
  4. Wait a moment.
  5. If you've coded correctly, an alert will display saying "less than".
  6. Dismiss the alert by clicking OK.
  7. For help with this code, see Chapter 13 in the book.