while loop in javascript code example
Example 1: javascript while
var i=0;
while (i < 10) {
console.log(i);
i++;
}
var i=0;
while(true){
i++;
if(i===3){
break;
}
}
Example 2: do while javascript
do {
} while (conditional);
Example 3: do while loop in javascript
do {
text += "The number is " + i;
i++;
}
while (i < 10);
Example 4: while loops js
while (10 > 1) {
console.log("HI");
}
Example 5: javascript while loop
while (i < 10) {
text += "The number is " + i;
i++;
}
Example 6: do while javascript
var i = 0;
do {
text += "The number is " + i;
i++;
}
while (i < 5);