Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/394.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
需要Javascript中的do while帮助吗_Javascript_Loops_While Loop - Fatal编程技术网

需要Javascript中的do while帮助吗

需要Javascript中的do while帮助吗,javascript,loops,while-loop,Javascript,Loops,While Loop,我需要一个do-while循环,直到三个特定单词中的一个写在提示框中 比如说 do var test = prompt(""); while test =! word1 word2 word3 当三个字中的一个写完后,脚本应该继续。 我试了两个多小时,但还是没有解决问题 请帮忙。试试这个 while (test != word1 && test != word2 && test != word3) { var test = prompt();

我需要一个do-while循环,直到三个特定单词中的一个写在提示框中

比如说

do 
    var test = prompt("");
while test =! word1 word2 word3
当三个字中的一个写完后,脚本应该继续。 我试了两个多小时,但还是没有解决问题

请帮忙。

试试这个

while (test != word1 && test != word2 && test != word3) {
    var test = prompt();
}
使用以下命令:

while (test != word1 && test != word2 && test != word3)

我尝试了两个多小时,但仍然无法解决问题您的比较运算符是反向的不=!,你必须对每个单词进行测试,测试!=word1&测试=word2&测试!=word3I建议你停止尝试,在继续下一步之前,找一本针对初学者的书或一个教程网站。在任何语言中,要实现几乎所有的事情,都需要对条件句有正确的理解。