Predict for...of Output
Predict Output Easy
Question
What does this code print?
Code
const fruits = ["apple", "banana", "cherry"];
for (const fruit of fruits) {
console.log(fruit);
}
Hint
for...of iterates over values of an iterable.
Explanation
for...of iterates over the values of an iterable (like an array). Each iteration, fruit takes the next element: first "apple", then "banana", then "cherry". Each is printed on its own line.
Related Resources
Related Lessons
- Loops
Learn about for...of.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.