I find a biggest problem with toFixed(2) i.e. if i write 5.555 then it will display 5.55 and if I write 5.565 then it will display 5.57. What should I do?
This is what i am doing. Declaring one array and toFixed all values of first array and put in second array.
var arr1 = [25.205,25.215,25.225,25.235,25.245,25.255,25.265,25.275,25.285,25.295]
var arr2 = []
for(i=0;i<10;i++){ arr2[i]= +arr1[i].toFixed(2) }
Results:
arr1 = [25.205, 25.215, 25.225, 25.235, 25.245, 25.255, 25.265, 25.275, 25.285, 25.295]
arr2 = [25.2, 25.21, 25.23, 25.23, 25.25, 25.25, 25.27, 25.27, 25.29, 25.3]
should i have to use the Math.floor()
method of the Math object for this.
Math.floor(number*100)/100