Video Lesson

Lesson Notes

Looping Over Array Items in JavaScript

Iterating over an array lets you perform actions on each element. You can use a classic for loop:

1const names = ["John", "Mary", "Susie", "Jay", "Edward", "Mike"]; 2 3for (let i = 0; i < names.length; i++) { 4 console.log(`Index ${i}: value is ${names[i]}`); 5}
  • Initialization: let i = 0
  • Condition: i < names.length (stops after the last index)
  • Increment: i++ (moves to the next index)

How It Works

  1. i starts at 0.
  2. Runs the loop body while i < names.length (6).
  3. Accesses each element by names[i] for indexes 0…5.
  4. Stops when i reaches 6.

AI Assistant

Sign In Required

Sign in and subscribe to use the AI assistant for instant help with your lessons.

Sign In

Array Iteration with JavaScript For Loops

In this lesson, you'll master the art of looping over array items in JavaScript using the classic `for` loop. Discover how to efficiently access and manipulate each element within an array, enhancing your programming skills and enabling you to handle data with confidence!

2m 40s

Course Content

0 of 32 lessons completed
6. Promises, Async and Await
0 of 0 completed
7. The DOM
0 of 0 completed