Skip to content Skip to sidebar Skip to footer

Javascript Number Placing And How To , 4 = 0.04, 14 = 0.14, 100 = 1.00

I am trying to write a custom calculator but I am having trouble trying to work out a figure, I want to be able to add decimal points before the number which has been in puted. For

Solution 1:

>>> [4, 14, 100].map(function(n) { return (n / 100).toFixed(2) })
["0.04", "0.14", "1.00"]

Solution 2:

How about this?

var num = 4; var fig = num * 0.01;

Post a Comment for "Javascript Number Placing And How To , 4 = 0.04, 14 = 0.14, 100 = 1.00"