My variable storing the value 2.448, like this:
var prIceCream = 2.448
I want to show in the browser this decimal number with two places after the floating point.
prIceCream.toFixed(2)
document.writeln(`Value: ${prIceCream}`)
But the browser doesn't display as it should, while in the terminal it works:
I tried it another way, writing toFixed(2) inside the Template String, after my variable, like this:
var prIceCream = 2.448
document.writeln(`Value: ${prIceCream.toFixed(2)}`)
This solved my problem! But why didn't it work outside of document.writeln, as I wrote before?