k00*_*00k 1 javascript math formula integer-division
除了以下问题,不确定问这个问题的最佳方式:
我正在编写一个接受名为'x'的变量的函数.
function doIt(x){
var y = someformula; //this is just a placeholder for the correct formula
return y;
}
Run Code Online (Sandbox Code Playgroud)
这就是我期望的回报:
if (x is between 0 and 9){ y = 0; }
if (x is between 10 and 19){ y = 32; }
if (x is between 20 and 29){ y = 64; }
if (x is between 30 and 39){ y = 96; }
Run Code Online (Sandbox Code Playgroud)
等等....
任何帮助表示赞赏.
如果重要的话,我是用JavaScript做的.