JavaScript相當新穎如果用戶輸入錯誤答案並且我想讓問題重複,直到他們得到正確答案,我該如何循環回提示問題。如果回答不正確,我該如何循環回提示符javascript
<html>
<head>
<script>
</script>
<title> Javascript program</title>
</head>
<body>
<script>
var company = (prompt("What the name of the company that developed the javascript language?", ""));
if (company == 'netscape') {
alert("correct answer!");
} else {
alert("wrong answer");
}
</script>
</body>
</html>
看一看a ['while'](https://developer.mozilla。org/en-US/docs/Web/JavaScript/Reference/Statements/while)循環。順便說一句,如果有人輸入「Netscape」而不是「netscape」,會發生什麼情況。 – Tigger
要添加到答案,你也可以使用do while循環[如此處所示](http://stackoverflow.com/questions/15047140/javascript-prompt-number-and-continue-prompting-if-answer-is -wrong#answer-15047174) –