JavaScript Math Object — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Math Object lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Exercises(5)
- 1
Remove the sign
easy10 minReport the absolute value of minus five.
- 2
Find a square root
easy10 minReport the square root of 144.
- 3
Raise to a power
easy10 minUse Math.pow to report two to the tenth.
- 4
Measure a distance
easy10 minReport how far apart three and eight are.
- 5
Work out a circle area
medium10 minReport the rounded area of a circle of radius three.
Find the bug(5)
- 1
Fix Math used with new
easy8 minMath is not a constructor.
- 2
Fix the missing Math prefix
easy8 minsqrt is a method of Math, not a global function.
- 3
Fix the distance without abs
easy8 minThe difference is negative, so the sign must be removed.
- 4
Fix PI written by hand
easy8 minUse the built-in constant rather than a rough value.
- 5
Fix the arguments to pow swapped
easy8 minThe base comes first and the exponent second.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace