Loop in JavaScript until a condition is met
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.