我不知道像 1>=5, 6>=10, 11>=15 这样隐藏 int
...
我不知道这是如何调用的,但我认为这个例子可以解释我的问题......
1 = 5
2 = 5
3 = 5
4 = 5
5 = 5
6 = 10
7 = 10
8 = 10
9 = 10
10 = 10
11 = 15
//and more..
所以JS
var x = 1;
var result = (???) // 5
最佳答案
这应该可以解决问题:
Math.floor((x-1)/5 + 1) * 5
简单版本(@RichardTowers):
Math.ceil(x/5) * 5
关于javascript - 转换模式中的整数 (1>=5, 6>=10, 11>=15 ...),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18954500/