Answers for "9.6.3. for Loops Rewritten as while Loops"

0

9.6.3. for Loops Rewritten as while Loops

/*We can use the while loop to create any type of iteration we wish, 
including anything that we have previously done with a for loop. 
For example, consider our initial for loop example.*/

for (let i = 0; i < 51; i++) {
   console.log(i);
}

//This can be rewritten as a while loop:

let i = 0;

while (i < 51) {
   console.log(i);
   i++;
}
Posted by: Guest on June-18-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language