while true js 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 loop in javascript
do {
text += "The number is " + i;
i++;
}
while (i < 10);
Example 3: javascript while loop
while (i < 10) {
text += "The number is " + i;
i++;
}
Example 4: javascript while loop
while(condition) {
}
Example 5: boucle for in js
let panier = ['fraise', 'banane', 'poire'];
for (const fruit in panier) {
console.log(panier[fruit]);
}
Example 6: boucle for of javascript
let panier = ['fraise', 'banane', 'poire'];
for (const fruit of panier) {
console.log(panier.indexOf(fruit));
}