I am trying to convert a var to a 2 decimal point number in Javascript, as follows:
var num1 = 9.7000000000
var newNum1= Math.floor(parseFloat(num1) * 100) / 100;
However, the output turns out to be 9.69.
I appreciate any help or advice.
Edit: Thanks everyone, I have also tried .toFixed(2).
However, I encountered issues when using it with arithmetic functions afterwards:
if (weight < newNum1)
Resolved: By adding a unary plus operator + as follows:
newNum1= +num1.toFixed(2);
 
     
     
     
     
     
    