gpt4 book ai didi

javascript - 我可以用一个数学公式来表达这些条件吗?

转载 作者:行者123 更新时间:2023-11-30 07:11:31 24 4
gpt4 key购买 nike

不确定问这个问题的最佳方式,除了:

我正在编写一个函数,它将接受名为“x”的变量。

function doIt(x){
var y = someformula; //this is just a placeholder for the correct formula
return y;
}

这是我期望返回的内容:

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; }

等等....

感谢任何帮助。

如果重要的话,我会用 JavaScript 来做。

最佳答案

return Math.floor(x/10) * 32;

关于javascript - 我可以用一个数学公式来表达这些条件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3578258/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com