Reputation: 41
I was trying to convert this "for loop"
for(rows=0;rows<26;rows++ ){
for(seats=0;seats<100;seats++ ){
console.log(rows+"-"+seats);
}
}
to a while loop in javaScript and that's what I got
rows=0;
seats=0;
while(rows<26){
while(seats<100){
console.log(rows+"-"+seats);
seats++;
}
rows++ ;
}
but the output wasn't the same and I think there is an issue with the while loop that I don't know .. I hope that anyone can help
Upvotes: 0
Views: 38
Reputation: 4562
You need to reset seats = 0 for each row.
rows=0;
seats=0;
while(rows<26){
seats = 0;
while(seats<100){
console.log(rows+"-"+seats);
seats++;
}
rows++;
}
Upvotes: 1