Home » Javascript » Javascript toFixed() is not working as expected

Javascript toFixed() is not working as expected

Posted by: admin August 19, 2018 Leave a comment

Questions:

I am using toFixed but the method does not operate as expected

parseFloat(19373.315).toFixed(2);

//19373.31   Chrome 

Expected Output : 19373.32

parseFloat(9373.315).toFixed(2);
// 9373.32  Working fine

Why does the first example round down, whereas the second example round up?

Answers: