while loops js
var i=0; while (i < 10) { console.log(i); i++; } //Alternatively, You could break out of a loop like so: var i=0; while(true){ i++; if(i===3){ break; } }
Here is what the above code is Doing:
1. We create a variable called i and set it to 0.
2. We create a while loop that will run as long as i is less than 10.
3. We log the value of i to the console.
4. We increment i by 1.
5. We close the while loop.