181
rated 0 times
[
188]
[
7]
/ answers: 1 / hits: 92476
/ 8 Years ago, wed, december 21, 2016, 12:00:00
How to get following inputs to bellow outputs
Input
1.0789
10.350
1.7777
Output
1.07
10.35
1.77
More From » javascript
How to get following inputs to bellow outputs
Input
1.0789
10.350
1.7777
Output
1.07
10.35
1.77
Use Math.floor
to round the decimal places under the current value.
Example
Math.floor(1.0789 * 100) / 100
Working Fiddle
console.log(Math.floor(1.0789 * 100) / 100);
console.log(Math.floor(10.350 * 100) / 100);
console.log(Math.floor(1.7777 * 100) / 100);
console.log(Math.floor(12.34 * 100) / 100);