javascript return result while looping 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: while loops js
while (10 > 1) {
console.log("HI");
}