【发布时间】:2019-07-30 16:01:27
【问题描述】:
这个程序会打印出“没人忙,这只是一个优先事项”。如果用户对时间问题回答“否”,我希望它说如果您对时间问题回答“否”并且对至少一个其他问题回答“是”。如果您对所有问题都回答“否”,则应改为“您不是来自我们”。我不确定如何更改此代码以获得此结果。
var javascript = prompt("Want to learn javascript? (Type yes or no)");
var docker = prompt("Want to learn docker? (Type yes or no)");
var time = prompt ("do you have time ? (type yes or no)");
if(time === "no") {
alert("Nobody is busy its just a matter of PRIORITIES");
}
if ((javascript ==="yes" && time === "yes") && (docker === 'yes' && time ==='yes') ) {
alert("keep patience first learn docker and then learn javascript");
}
else if (javascript === "yes" && docker === "yes") {
if (time === "no") {
alert("so what should I do if u don't have time ?");
}
}
else if (javascript ==="yes" && time === "yes") {
alert("go and learn javascript");
}
else if (time ==='no' && javascript === "yes") {
alert("\"A smarter way to learn javascript\" will solve your problem in less time ");
}
else if (docker === 'yes' && time ==='yes') {
alert(' go n learn docker');
}
else if (time ==='no' && docker === "yes") {
alert("\"Docker Deep Dive\" will solve your problem in less time ");
}
else {
alert('You are not from us');
}
【问题讨论】:
-
请详细说明您面临的问题是什么?
-
你似乎没有真正问过任何问题?
-
他的问题在标题中,我猜他的代码有效,但意识到有更好的方法。我猜他正在寻找开关盒的解释。
-
您错过了实际问题。 stackoverflow.com/help/how-to-ask
-
你的第一个 if(time === "no") allways if time is no 会显示警报.....
标签: javascript html if-statement conditional conditional-statements