+ 1

Code for javascript

how to round to 2 decimal places ,,, if the 3nd decimal is equal to 5 ( if the 2nd decimal is even, the 2nd decimal number is increased by 1 and if the even number is fixed) // example : 2.215 = 2.22 and 2.245 = 2.24

12th Aug 2022, 2:37 PM
Zulpakar
Zulpakar - avatar
2 Answers
+ 3
console.log( Number(parseFloat("123.456").toFixed(2)) ); // or console.log( Math.round( 123.456 * 100 ) / 100 );
12th Aug 2022, 3:03 PM
SoloProg
SoloProg - avatar
+ 1
Thanks for help me this code working SoloProg 🙏
13th Aug 2022, 4:26 AM
Zulpakar
Zulpakar - avatar