Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Loop Through Arrays with for | Mastering JavaScript Arrays
JavaScript Data Structures

bookChallenge: Loop Through Arrays with for

Task

You are given an array of Ford car models. The task is to create a for loop to iterate through the array and log each model.

  1. Use a for loop to iterate through the fordCarModels array.
  2. Inside the for loop, log each model to the console using console.log().
123456
const fordCarModels = ["Mustang", "F-150", "Explorer", "Expedition", "Taurus"]; // Use a `for` loop to iterate and log models for (let ___; i < ___.length; i += 1) { console.log(___); }
copy

Expected Output:

Mustang
F-150
Explorer
Expedition
Taurus
  1. To create a for loop, use the following syntax: for (let i = 0; i < array.length; i += 1) { ... }.
  2. Use console.log() to log each model inside the for loop.
123456
const fordCarModels = ["Mustang", "F-150", "Explorer", "Expedition", "Taurus"]; // Use a `for` loop to iterate and log models for (let i = 0; i < fordCarModels.length; i += 1) { console.log(fordCarModels[i]); }
copy

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 4. ChapterΒ 6

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

bookChallenge: Loop Through Arrays with for

Task

You are given an array of Ford car models. The task is to create a for loop to iterate through the array and log each model.

  1. Use a for loop to iterate through the fordCarModels array.
  2. Inside the for loop, log each model to the console using console.log().
123456
const fordCarModels = ["Mustang", "F-150", "Explorer", "Expedition", "Taurus"]; // Use a `for` loop to iterate and log models for (let ___; i < ___.length; i += 1) { console.log(___); }
copy

Expected Output:

Mustang
F-150
Explorer
Expedition
Taurus
  1. To create a for loop, use the following syntax: for (let i = 0; i < array.length; i += 1) { ... }.
  2. Use console.log() to log each model inside the for loop.
123456
const fordCarModels = ["Mustang", "F-150", "Explorer", "Expedition", "Taurus"]; // Use a `for` loop to iterate and log models for (let i = 0; i < fordCarModels.length; i += 1) { console.log(fordCarModels[i]); }
copy

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 4. ChapterΒ 6
some-alt