Question : How to Loop Through an Array with a do…while Loop in JavaScript
Answered by : godswill-ohiole-agangan
const scores = [22, 54, 76, 92, 43, 33];
let i = 0;
do { console.log(scores[i]); i++;
} while (i < scores.length);
// will return
// 22
// 54
// 76
// 92
// 43
// 33
Source : https://www.freecodecamp.org/news/how-to-loop-through-an-array-in-javascript-js-iterate-tutorial/ | Last Update : Fri, 01 Jul 22
Question : How to Loop Through an Array with a While Loop in JavaScript
Answered by : godswill-ohiole-agangan
const scores = [22, 54, 76, 92, 43, 33];
let i = 0;
while (i < scores.length) { console.log(scores[i]); i++;
}
// will return
// 22
// 54
// 76
// 92
// 43
// 33
Source : https://www.freecodecamp.org/news/how-to-loop-through-an-array-in-javascript-js-iterate-tutorial/ | Last Update : Fri, 01 Jul 22