for(var i = 0; i < 10; i++) {

console.log(i);

}

The above loop will run for 10 times exactly and then stop. Here’s what’s going on here:

It’s important to understand that when we define our condition statement, we must define a condition that can ‘break’ or the loop will run forever. This just means that we must write a condition that will at some stage return FALSE as a result of our loop running.

Let’s see a for loop in the context of looping through an array and picking off values.