0
コードが正しく動作しません。ループを継続していません。それはあなたの価値が低いか高いかを示し、そこでそれを止めるだけです。なぜそれはループを維持しないのですか?コードがループを停止します
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