How do I round a number in JavaScript?

后端 未结 8 2160
余生分开走
余生分开走 2020-11-27 03:20

While working on a project, I came across a JS-script created by a former employee that basically creates a report in the form of

Name : Value
Name2 : Value2         


        
8条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-27 04:04

    You can also use toFixed(x) or toPrecision(x) where x is the number of digits.

    Both these methods are supported in all major browsers

提交回复
热议问题