Nearby lessons

17 of 40

🔂 JavaScript for Loop

📌 What is JavaScript for Loop?

The for loop repeats a block of code a specific number of times.

Perfect when you know exactly how many iterations you need.

📋 for Loop Basics

AttributeDescription
Syntaxfor (initialization; condition; increment)
InitializationExecutes once before loop starts
ConditionEvaluated before each iteration
IncrementExecuted after each iteration

🔹Print 1 to 10 Using for loop

Example03
Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

🔹Print 10 to 1 Using for loop

Example04
Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

🔹Print Even Number Using for loop

Example05
Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

🔹Print Odd Number Using for loop

Example06
Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

🔁 Nested for Loops

AttributeDescription
UsageCreating grids/multi-dimensional arrays
Outer LoopControls rows
Inner LoopControls columns
Example07
Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

🧠 Test Your Knowledge

2 Questions
Progress: 0 / 2