JavaScript · Junior · Question 11 of 75
What does 0.1 + 0.2 === 0.3 evaluate to?
- ✓Correct answer:
false - 2
true - 3
TypeError
Explanation
Numbers are stored in binary IEEE-754 format, and 0.1 and 0.2 can't be represented exactly - the sum is 0.30000000000000004. Compare numbers with a tolerance (Math.abs(a - b) < Number.EPSILON), and handle money as integer cents.