Reputation: 1
I have question regarding JavaScript toFixed(). I am facing some difference in rounding,
let num1=1.635;
let num2=10.635;
console.log(num1.toFixed(2)); // I am getting the output as 1.64 which is correct.
console.log(num2.toFixed(2)); // but now I am getting 10.63 instead of 10.64.
can anyone explain about this behavior of the above code and suggest how to overcome this?
Upvotes: 0
Views: 37