gpt4 book ai didi

javascript - switch case js的两个参数

转载 作者:行者123 更新时间:2023-11-30 11:45:22 25 4
gpt4 key购买 nike

请告诉我如何使用两个参数并将此代码简化为正常状态。谢谢你!这个逻辑对我来说是非常必要的,希望大家多多包涵。

var treshhold_two = 0;

function Test(attack, ratio) {
switch (attack) {
case 0,01:
switch (ratio) {
case 2:
treshhold = 2798,6;
break;
case 4:
treshhold = 3678,16;
break;
case 6:
treshhold = 5757,12;
break;
}
break;
case >0,01:
switch (attack, ratio) {
case 0,03,2:
treshhold = -5,75712;
break;
case 0,03,4:
treshhold = -5,75712 * 1,1;
break; // -45%
case 0,03,6:
treshhold = -5,75712 * 0,96;
break; // -52%, and etc.
...
}
break;
}
}

最佳答案

尝试:

var treshhold_two = 0;

function Test(attack, ratio) {
if(attack == 0,01) {
switch (ratio) {
case 2:
treshhold = 2798,6;
break;
case 4:
treshhold = 3678,16;
break;
case 6:
treshhold = 5757,12;
break;
}
}
else {
switch (attack) {
case 0,03:
if(ratio==2) treshhold = -5,75712;
if(ratio==4) treshhold = -5,75712 * 1,1;
if(ratio==6) treshhold = -5,75712 * 0,96;
break;
...
}
}
}

关于javascript - switch case js的两个参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41161658/

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