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;
}
}
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;
}
}
The code will loop while searchArray result is not false and until it becomes false. So the code is correct if you wanted to achieve such behavior and it's not correct otherwise.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With