[SOLVED] How to round the float number | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

[SOLVED] How to round the float number

I want to round number from 10.6999 to be 10.70 but when i am using Math.round function i got 11 My question is how to round number from 10.6999 to 10.70 in javascript https://code.sololearn.com/W4rX2Q09Ft15/?ref=app

13th Apr 2022, 8:57 AM
EsaKurniawan
3 Antworten
0
You can try like: console.log(Math.round(number*100)/100);
13th Apr 2022, 9:26 AM
Jayakrishna 🇮🇳
0
Already solved it with toFixed() function man, But your solution are working too
13th Apr 2022, 10:41 AM
EsaKurniawan
0
Yes. That also works.. edit: number.toFixed(2); just got it
13th Apr 2022, 11:00 AM
Jayakrishna 🇮🇳