round to nearest .25 javascript

后端 未结 8 688
我在风中等你
我在风中等你 2020-12-08 14:07

I want to convert all numbers to the nearest .25

So...

5 becomes 5.00
2.25 becomes 2.25
4 becomes 4.00
3.5 becomes 3.50

Thanks

8条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-08 14:45

    Multiply by 4, round to integer, divide by 4 and format with two decimals.

    Edit Any reason for the downvotes? At least leave a comment to know what should be improved.

提交回复
热议问题