Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
42
rated 0 times [  43] [ 1]  / answers: 1 / hits: 82366  / 9 Years ago, tue, january 26, 2016, 12:00:00

I'm trying to loop indefinitely until a condition is met...is the following correct?



It seems not to be.



    var set = false;
while(set !== true) {
var check = searchArray(checkResult, number);
if(check === false) {
grid.push(number);
set = true;
}
}

More From » while-loop

 Answers
14

Basically, you can make an infinite loop with this pattern and add a break condition anywhere in the loop with the statement break:



while (true) {
// ...
if (breakCondition) {
break;
}
}

[#63557] Saturday, January 23, 2016, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ayleen

Total Points: 447
Total Questions: 88
Total Answers: 109

Location: Belize
Member since Mon, Jun 20, 2022
2 Years ago
;