-1

I have 2 number that I use Math.round to round it,for example I want if my number is 900.20 it rounded to 900.00 and if 12.80 it rounded to 13. I use Math.round but 900.20 rounded to 910.00 but 12.8 rounded to 13 correctly.

var num1=900.20;
var num2=12.80;

var result1=  Math.round(num1.toFixed(2));
var result2=  Math.round(num2.toFixed(2));
ddb
  • 2,423
  • 7
  • 28
  • 38
Motion
  • 116
  • 1
  • 11

1 Answers1

1

Why you are using .toFixed() function ? Just use Math.round() function and it will work. You don't need to convert it to string.

Qsprec
  • 265
  • 3
  • 11