JS while 循环求助~
如代码:<html>
<head>
</head>
<body>
<script>
var guessWord = prompt("What word am I think of?");
while (guessWord != "sandwich")
{
prompt("No, That's not right, plz input again: ");
}
alert ("You're right! Congratulations!");
</script>
</body>
</html>
这是一个简单的用while循环,猜字的小程序,但在运行的时候出现一个问题,如果第一次输入的是:sandwich ,那么可以正常跳出while循环,并显示alert内容,而如果第一次输入错误的答案,之后再输入正确的答案sandwich,都无法跳出while循环,刚学JS几天,望各位有经验的小伙伴帮忙解答,感谢~~~ while (guessWord != "sandwich")
{
guessWord = prompt("What word am I think of?");
} ba21 发表于 2018-3-30 13:34
while (guessWord != "sandwich")
{
感谢~~没想到是这么简单的错误~~{:10_247:}
页:
[1]