Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
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

 Answers
194

Use Math.floor to round the decimal places under the current value.


Reference


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);




[#59625] Monday, December 19, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
denzelc

Total Points: 637
Total Questions: 89
Total Answers: 88

Location: Liechtenstein
Member since Wed, Dec 8, 2021
3 Years ago
;