Cash Register challenge

I did everything right, but I came across problem with freecodecamp floating point compiler when I reduce 60 from 94.74 it becomes 34.7399999999995
image
What could I do for solving that?

You can use toFixed() method to reduce a number to a fixed point notation. Note the result will be as a string (you can convert it back to number using the parseFloat).

You can also keep track of pennies instead of dollars in your calculations.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.