How FOR loop works
In the example code below the loop flows through these steps: Setting initial variable value of i to 0 Testing if the loop should be running while i is 0 Running the code block console.log(i) Updating i to be 1 Testing if the loop should be running while i is 1 Running the code block console.log(i) Updating i to be 2 Testing if the loop should be running while i is 2 This means the code will log 0 and 1 to the console.
for (let i = 0; i < 2; i++) {
   console​.log(i)
}
by Valeri Tandilashvili
2 years ago
JavaScript
FOR loop
0
Pro tip: use ```triple backticks around text``` to write in code fences