I tried that already by using var.toFixed(2),
but this is running in a TypeError: toFixed is not a function.
This happens only when the script is running over such an affected value, for other values toFixed is working.
My guess is that the number if actually a string, use typeof to check what type it is. If it’s a string then it wouldn’t have toFixed because that’s for numbers. If it is a string then perhaps try a parseFloat as a workaround.
Sorry, but that’s life when using floating point (non-integer) numbers in a general-purpose computer. It’s not anybody’s bug. It’s down to the fact that the representation of arbitrary floating point numbers in a fixed number of bits in the hardware can result in the computer being unable to represent some values exactly. So, for example, a floating point calculation which should result in 2.000 might instead give 1.99999…