Number Inspector
JavaScript
20 pts
Number Inspector
Create four values and inspect each with the right Number method or property:
people=8100000000(the world population). Print"People safe:"and whether it is a safe integer.ants=20000000000000000. Print"Ants safe:"and whether it is a safe integer.ratio="many" / 2. Print"Ratio is NaN:"and the result ofNumber.isNaN.diff=0.1 + 0.2 - 0.3. Print"Tiny difference:"anddiff < Number.EPSILON.
Expected output:
People safe: true Ants safe: false Ratio is NaN: true Tiny difference: true
Checklist
- Create
peopleandantsand check them. - Create
ratioand test it for NaN. - Create
diffand compare it withEPSILON. - The four lines match.
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
