Challenge: Loop Through Arrays with for
Swipe to show menu
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.
- Use a
forloop to iterate through thefordCarModelsarray. - Inside the
forloop, log each model to the console usingconsole.log().
123456const fordCarModels = ["Mustang", "F-150", "Explorer", "Expedition", "Taurus"]; // Use a `for` loop to iterate and log models for (let ___; i < ___.length; i += 1) { console.log(___); }
Expected Output:
Mustang
F-150
Explorer
Expedition
Taurus
- To create a
forloop, use the following syntax:for (let i = 0; i < array.length; i += 1) { ... }. - Use
console.log()to log each model inside theforloop.
123456const 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]); }
Everything was clear?
Thanks for your feedback!
SectionΒ 1. ChapterΒ 27
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
SectionΒ 1. ChapterΒ 27