Iterate with JavaScript Do...While Loops code example
Example 1: javascript while loop
while (i < 10) {
text += "The number is " + i;
i++;
}
Example 2: Iterate with Do While Loops Javascript
var myArray = [];
var i = 10;
do {
myArray.push(i);
i++;
} while (i < 5)
console.log(i, myArray);
Example 3: Iterate with JavaScript Do...While Loops
var ourArray = [];
var i = 5;
do {
ourArray.push(i);
i++;
} while (i < 5);
Example 4: Iterate with JavaScript While Loops
var ourArray = [];
var i = 0;
while(i < 5) {
ourArray.push(i);
i++;
}
var myArray = [];
var i = 5;
while (i >= 0) {
myArray.push(i);
i--;
}