while true loop javascript code example
Example 1: example of while loop in javascript with array length
var soccerTeams = ['Barca','Madrid','Gunners','City','PSG']
var x=0;
while( x <= soccerTeams.length) {
console.log(soccerTeams[x])
x++;
}
======== output ===========
Barca
Madrid
Gunners
City
PSG
undefined
5
Example 2: javascript while loop
while (i < 10) {
text += "The number is " + i;
i++;
}