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

Given the following statement, write a statement that assigns the highest number to the variable big. let x = 3, y = 2, z = 1; let big = Math.max(x, y, z); letbig=Math\.max\(x,y,z\);
Given the following statement, write a statement that assigns the lowest number to the variable small. let x = 3, y = 2, z = 1; let small = Math.min(x, y, z); letsmall=Math\.min\(x,y,z\);
Code a statement that finds the sign of the number represented by y and assigns it to x, which hasn't been declared beforehand. let x = Math.sign(y); letx=Math\.sign\(y\);
Code a statement that finds the square root of 64 and assigns it to x, which hasn't been declared beforehand. let x = Math.sqrt(64); letx=Math\.sqrt\(64\);
Code a statement that throws away the decimal part of 1.09 and assigns the result to x, which hasn't been declared beforehand. let x = Math.trunc(1.09); letx=Math\.trunc\(1\.09\);
Code a statement that raises 4 to the third power and assigns the result to x. let x = Math.pow(4, 3); letx=Math\.pow\(4,3\);
Given the following statement, code an alert that displays the largest number multiplied by 3. let x = 3, y = 2, z = 1; alert(Math.max(x, y, z) * 3); alert\(Math\.max\(x,y,z\)\*3\);
Given the following statement, code an alert that displays the largest number multiplied by the smallest number. let x = 3, y = 2, z = 1; alert(Math.max(x, y, z) * Math.min(x, y, z)); alert\(Math\.max\(x,y,z\)\*Math\.min\(x,y,z\)\);
  1. Code an alert that displays the sign of 0.
  2. Click the Result button (or, after revising, don't click, just wait).
  3. Wait a moment.
  4. If you've coded correctly, an alert will display 0.
  5. Dismiss the alert by clicking OK.
  6. For help with this code, see Chapter 42 in the book.
  1. Code an alert that displays the square root of 64 multiplied by 2 to the second power.
  2. Click the Result button (or, after revising, don't click, just wait).
  3. Wait a moment.
  4. If you've coded correctly, an alert will display 64.
  5. Dismiss the alert by clicking OK.
  6. For help with this code, see Chapter 42 in the book.