How am I to get second decimal place 0?
For example:
15.296326 => 15.30
15.245152 => 15.20
I have tried toFixed()
and Math.Floor
but could not get the expected answer.
How am I to get second decimal place 0?
For example:
15.296326 => 15.30
15.245152 => 15.20
I have tried toFixed()
and Math.Floor
but could not get the expected answer.
function roundFloat(n) {
return (Math.round(n * 10) / 10).toFixed(2);
}
roundFloat(15.296326); // "15.30"
roundFloat(15.245152); // "15.20"