Friday, 9 August 2013

stuck with Javascript infinite while loop

stuck with Javascript infinite while loop

My apologies for the n00b question, I've tried looking through infinite
loop related issues but they're way more complex:
var replay = 1;
while (replay = 1) {
replay = prompt("Yes(1) or No(0) ?");
}
How come this is an infinite loop?
I thought this while loop would only continue iterating while the replay
variable has a value of 1.
However it doesn't stop even when user input is 0, or anything else for
that matter.
Thanks in advance for any of your input!

No comments:

Post a Comment