gpt4 book ai didi

javascript - 为什么我的代码不从 if 语句输出字符串?

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

这是我的代码:https://plnkr.co/edit/HFyKq2JZipwAAST0iNAt?p=preview为什么不将 if 语句的结果输​​出到 ID 为“WA”的标签这是与上面链接的代码分开的 IF 语句:

if (demlean.WA <= 5 && demlean.WA >= -5) {
if (demlean.WA > 0) {
var lWA = "Tossup, Tilt D";
} else if (demlean.WA < 0) {
var lWA = "Tossup, Tilt R";
} else {
var lWA = "Absolute Tossup";
}

} else if (demlean.WA > 5) {
if (demlean.WA <= 10) {
var lWA = "Lean D";
} else if (demlean.WA <= 17) {
var lWA = "Likely D";
} else {
var lWA = "Safe D";
}
} else {
if (demlean.WA >= -10) {
var lWA = "Lean R";
} else if (demlean.WA >= -17) {
var lWA = "Likely R";
} else {
var lWA = "Safe R";
}
}
.... // more code

最佳答案

好的,我终于可以运行您的代码了,这是我所做的修改。首先,

Uncaught ReferenceError: dDe is not defined
at calc ((index):140)
at submit ((index):153)
at HTMLButtonElement.onclick ((index):167)

所以我将这一行更改为 DE: dDE,。然后另一个错误

Uncaught ReferenceError: demlean is not defined
at lean ((index):45)
at calc ((index):146)
at submit ((index):153)
at HTMLButtonElement.onclick ((index):167)

demlean 是一个局部变量。所以我需要将其传递给精益功能。

    .....
var geba;
var tda;
/* If Statement for determing lean in variable lSTATE */
function lean(demlean) {
.....
.
.
.
DE: dDE,
MD: dMD,
NY: dNY,
VT: dVT,
ME: dME,
HI: dHI
};
// passing demlean here.
lean(demlean);

希望对您有所帮助。这是更新后的代码链接:https://plnkr.co/edit/fGlSmDEWNEtKEZ7sLgUC?p=info

关于javascript - 为什么我的代码不从 if 语句输出字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48492969/

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