how to break the foreach loop in javascript 1

how to break the foreach loop in javascript

//break out of for loop
for (i = 0; i < 10; i++) {
    if (i === 3) { break; }
}

Here is what the above code is Doing:
1. The for loop is set to run 10 times.
2. The if statement checks to see if i is equal to 3.
3. If i is equal to 3, the break statement is executed, and the for loop is exited.

Similar Posts