Imagine you want to store the names of 5 friends. Which reason best explains why using an array is better than using 5 separate variables?
Think about how you would find the third friend's name if you had 5 separate variables.
Arrays group multiple items together so you can manage them easily by their position (index). This is simpler than handling many separate variables.
What is the output of this JavaScript code?
const fruits = ['apple', 'banana', 'cherry']; console.log(fruits[1]);
Remember, array indexes start at 0.
Arrays start counting at 0, so fruits[1] is the second item, 'banana'.
What will be the value of numbers.length after running this code?
const numbers = [1, 2, 3]; numbers.push(4); numbers.push(5); console.log(numbers.length);
Each push adds one item to the array.
Starting with 3 items, pushing 2 more adds 2, so length becomes 5.
Why are arrays useful when you want to repeat an action for many items?
Think about how you would print each item in a list of names.
Arrays let you use loops to access each item by its position, making repeated actions simple and efficient.
What is the output of this code?
const colors = ['red', 'green', 'blue'];
colors[1] = 'yellow';
console.log(colors.join('-'));Changing an array element updates that position. join('-') connects items with dashes.
The second item 'green' is replaced by 'yellow'. Joining with '-' creates 'red-yellow-blue'.