你需要帮助解决“var破坏性变量”的问题。我需要回答一下 “Y或N”。并在if
中放入第3个条件 <script type="text/javascript">
var examResult;
var attendance;
var disruptive;
examResult=parseInt(prompt("Enter Exam result:",""));
attendance=parseInt(prompt("Enter Attendance:",""));
disruptive=prompt("Disruptive Y/N:","");
if((examResult>=40) && (attendance>=75) &&("disruptive))
{
document.write("You have passed");
}
else
{
document.write("You have failed")
}
</script>
答案 0 :(得分:0)
试试这个
var examResult;
var attendance;
var disruptive;
examResult=parseInt(prompt("Enter Exam result:",""));
attendance=parseInt(prompt("Enter Attendance:",""));
disruptive=prompt("Disruptive Y/N:","");
if((examResult>=40) && (attendance>=75) &&(disruptive=="Y"))
{
concole.log("You have passed");
}
else
{
concole.log("You have failed")
}
答案 1 :(得分:0)
你的if语句有错误。删除“”(双引号),然后尝试
答案 2 :(得分:0)
在if语句之前添加此内容
disruptiveString=prompt("Disruptive Y/N:","");
if (disruptiveString == "Y"){
disruptive = true;
}
else{
disruptive = false;
}
同样如@Java Buddy所述,删除“在你的陈述中