ZELIBOBA Asked:2020-03-15 03:27:54 +0000 UTC2020-03-15 03:27:54 +0000 UTC 2020-03-15 03:27:54 +0000 UTC 将数字四舍五入到几十和几百 [重复] 772 我不知道如何编写可以四舍五入的代码。例如,我有 365,我需要将其四舍五入到 370,或者我有 350,我需要将其四舍五入到 400 javascript 1 个回答 Voted Best Answer Дмитрий Полянин 2020-03-15T03:37:15Z2020-03-15T03:37:15Z 我们是根据函数的使用来做的,该函数Math.round向上取整为整数。 function MyRound10(val) { return Math.round(val / 10) * 10; } console.log(MyRound10(33)); console.log(MyRound10(36)); console.log(MyRound10(145)); 的类似功能100。
我们是根据函数的使用来做的,该函数
Math.round向上取整为整数。的类似功能
100。