Hi all after working on my calculator project one area that i didnt expect to find problems with was the actual representation of the numbers after the calculation … turns out i got a lot of unexpected outcomes … others i did expect eg 7 divided by 3 would give 2.3333333333333335 so i googled how to sort this … first i got toPrecision() method then toFixed()

Using toFixed(2) i could output 2.33

But that didnt sort all problems if i had 0.0001 + 0.0001 i wanted 0.0002 but my output would be 0.00

so i set about creating a function to sort these problems out

then discovered more lol

so i have a function now created and it dose what i want it to do … but i would like some input on whether i missed an obvious easier solution.

so if you could look at the repl sheet i did and your solution solves all my test cases i would love to know

Here is my repl … if you want to try other number combinations you think i missed open up another repl and copy and paste mine into it