9 6 3 for loops rewritten as while loops

Solutions on MaxInterview for 9 6 3 for loops rewritten as while loops by the best coders in the world

showing results for - "9 6 3 for loops rewritten as while loops"
Olivia
20 Oct 2018
1/*We can use the while loop to create any type of iteration we wish, 
2including anything that we have previously done with a for loop. 
3For example, consider our initial for loop example.*/
4
5for (let i = 0; i < 51; i++) {
6   console.log(i);
7}
8
9//This can be rewritten as a while loop:
10
11let i = 0;
12
13while (i < 51) {
14   console.log(i);
15   i++;
16}