cf.completefrontend

Predict the outputMedium

What does toFixed return for 0.1 + 0.2 and for 1.005?

What does this log?
const total = 0.1 + 0.2;
console.log(total);
console.log(total.toFixed(2));
console.log(total.toFixed(2) + 1);
console.log((1.005).toFixed(2));
console.log((8.345).toFixed(2));
console.log(Math.round(1.005 * 100) / 100);

The answer

Work out every line it logs, in order. Then check.

Checking your sign-in…