01 / 04
The same thing, written two ways
while and for are both tools for "do this repeatedly". The same result can be written either way.
The two below give exactly the same output. All that differs is where the parts are kept.
let i = 1;while (i <= 3) { console.log(i); i++;}for (let i = 1; i <= 3; i++) { console.log(i);}Result
1 2 3 1 2 3