How to show for loop using a flowchart in JavaScript?

The "for" loop includes loop initialization where we initialize our counter to a starting value. The initialization statement is executed before the loop begins, the test statement which will test if a given condition is true or not. If the condition is true, then the code given inside the loop will be executed, otherwise, the control will come out of the loop.

At the end comes the iteration statement where you can increase or decrease your counter. Let us see how to show for loop using flowchart in JavaScript:

For Loop Flowchart

START Initialize: i = 0 i < n? Yes Execute Loop Body Increment: i++ No END

Syntax

for (initialization; condition; increment/decrement) {
    // Loop body - code to execute
}

Example: Basic For Loop

// Print numbers from 1 to 5
for (let i = 1; i 

Iteration 1: Number is 1
Iteration 2: Number is 2
Iteration 3: Number is 3
Iteration 4: Number is 4
Iteration 5: Number is 5
Loop completed!

Flow Explanation

  1. START: Program execution begins
  2. Initialize: Set counter variable (i = 0)
  3. Test Condition: Check if i < n (loop condition)
  4. Execute Body: If condition is true, run loop body
  5. Increment: Update counter (i++)
  6. Repeat: Go back to condition check
  7. END: When condition becomes false, exit loop

Example: Array Iteration

let fruits = ["apple", "banana", "orange"];

for (let i = 0; i 

Index 0: apple
Index 1: banana
Index 2: orange

Conclusion

The for loop flowchart shows the cyclic execution pattern: initialization ? condition check ? body execution ? increment ? repeat. This visual representation helps understand how the loop controls program flow and when it terminates.

Updated on: 2026-03-15T22:03:36+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements