-1
I have the following value: 7500
How do I get that value as a final result: 75.00
, would like to use pure javascript only.
Other examples:
76000 > 760.00
1600 > 16.00
I tried toFixed but it didn’t work
var number = 76900
var value = parseFloat(Math.round(number * 100) / 100).toFixed(2)
console.log(value)//Esperava 769.00 como resultado
To confirm, you divided by 100 before using the
toFixed
? https://repl.it/@acwoss/AjarAshamedInstitute– Woss
I put an example of how I did @Andersoncarloswoss
– Stan
Why multiplied by 100 too?
– Woss
Takes the
* 100
, nor theMath.round
makes sense there :/ at least not at first sight. The.toFixed(2)
already solves almost "everything".– Guilherme Nascimento
solved, I took the * 100
– Stan