0
我的功能有问题。当我输入calculateTaxRate(10000,“联合”)时,它不会给我10%的正确答案。它正在返回“更好地致电会计师”。我不确定为什么还在发生。任何帮助向我解释这一点将不胜感激。税务功能问题(If/Else语句)
function calculateTaxRate(salary, status) {
if (status !== ("single" || "joint") || (salary > 74900)) {
return "Better call an accountant";
} else if (status == "single") {
if (salary <= 9225) {
return "10%";
} else if (9226 <= salary && salary <= 37450) {
return "15%";
} else {
return "25%";
}
}
if (status == "joint") {
if (0 <= salary && salary <= 18450) {
return "10%";
} else if (18451 <= salary && salary <= $74, 900) {
return "15%";
}
}
}
'状态==( “单” || “联合”)'没有做你的想法 - 你需要学习JavaScript语法 - 它不是无效的,但你基本上检查'if status!==“single”'only –