In this condition you should use while loop
while (condition)
statement
But you can also use for...of and forEach and same for loop like below:
You can use for...of
const iterable = 'boo';
for (const value of iterable) {
if(mycondition){
console.log(value);
}
}
OR
You can also use forEach
const items = ['item1', 'item2', 'item3']
const copyItems = []
items.forEach(function(item){
if(mycondition){
copyItems.push(item)
}
})
OR
for
for ([initialization]; [condition]; [final-expression])
statement
for (;;)
is an infinite loop equivalent to while (true) because there is no test condition.
for ( ; s < myArray.length ; s++)
is a loop with no initialization. s will point to the beginning and is incremented until it end.