Мой код не работает должным образом. Он не продолжает цикл. Это просто показывает, что ваше значение низкое или высокое и останавливает его там. Почему он не зацикливается?code stop looping
var target;
var count = 0;
var play;
var game;
function do_this() {
var choose = (Math.floor(Math.random() * 100));
target = choose + 1;
while (true) {
play = prompt("I am thinking of a no. between 1 and 100\n\n" + "enter the no.");
game = parseInt(play);
count = count + 1;
if (isNaN(game)) {
alert("Please enter integer value");
return false;
}
if ((game < 1) || (game > 100)) {
alert("Please enter the value between 1 and 100");
return false;
}
if (game < choose) {
alert("enter higher value");
return false;
}
if (game > choose) {
alert("enter lower value");
return false;
}
alert("You are correct\n\n" + "you took" + count + "to guess the game");
return true;
}
}
do_this()
Пожалуйста, пожалуйста, отформатируйте это, чтобы быть читаемым –
Возможный дубликат [Возвращает ли стоп цикла?] (Http://stackoverflow.com/questions/11714503/does-return-stop-a-loop) – showdev