Predict Array Access
Predict OutputBeginner
Question
What does this code print?
Code
const fruits = ["apple", "banana", "cherry"];
console.log(fruits[1]);
Hint
Arrays are zero-indexed: index 0 is the first element.
Explanation
fruits[0] is "apple", fruits[1] is "banana", fruits[2] is "cherry". Since arrays are zero-indexed, index 1 refers to the second element. The output is: banana
Related Resources
Related Lessons
- Arrays
Learn how to access array elements by index.
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.