Javascript number placing and how to , 4 = 0.04, 14 = 0.14, 100 = 1.00

后端 未结 2 336
悲哀的现实
悲哀的现实 2021-01-29 14:34

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.<

2条回答
  •  再見小時候
    2021-01-29 15:14

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

提交回复
热议问题