Numbers and Math
You should see
0.30000000000000004 false
true
0.30 0.3
1998.9999999999998 1999
3 -2 -3 3 -2
9 2 4 3.1416 1024
true true
true false false
8 1000 ff 11111111
1,234,567.891 26%NaN: the number that is not a number
const price = Number("free")
const total = price * 3
console.log(total, total === NaN, typeof total)NaN false numberAny arithmetic on a non-numeric string, undefined, or an invalid operation (0 / 0, Math.sqrt(-1)) gives NaN. It is contagious — every operation on it stays NaN — and it is the only value not equal to itself, so === NaN is always false.
Check with Number.isNaN(x) (not the global isNaN, which coerces). Validate inputs at the edge: const n = Number(input); if (Number.isNaN(n)) throw ….
const price = Number("free")
if (Number.isNaN(price)) {
console.log("not a price")
}19.99 * 100 is 1998.9999999999998. Work in integer cents, or use a decimal library. Interviewers ask about this in every language.