The while Loop
Recreate the challenge from the lecture Looping Arrays, Breaking and Continuing, but this time using a
while
loop (call the arraypercentages3
).Reflect on what solution you like better for this task: the
for
loop or thewhile
loop?
const percentages3 = [];
let i = 0;
while (i < populations.length) {
const perc = percentageOfWorld1(populations[i]);
percentages3.push(perc);
i++;
}
console.log(percentages3);