Section 1 - Instruction

Arrays are like containers that hold multiple related values in a specific order. Instead of creating separate variables for each item, you can store them all in one organized list.

Think of an array like a shopping list or a playlist—multiple items kept together in sequence.

Engagement Message

What's one real-world example where you naturally group related items together?

Section 2 - Instruction

Creating an array in JavaScript is straightforward. You use square brackets [] and separate items with commas:

let fruits = ["apple", "banana", "orange"];

This creates an array called fruits containing three string values in order.

Engagement Message

Which symbol here tells JavaScript you're creating an array?

Section 3 - Instruction

Arrays can hold different types of data—numbers, strings, booleans—or even mix them together:

let gameStats = [150, "player1", true, 42];

This flexibility makes arrays perfect for storing various related information about the same topic.

Engagement Message

What mix of data types might you store for a user profile?

Section 4 - Instruction

To access individual items in an array, you use their position number, which is called an index. The index goes inside square brackets:

let colors = ["red", "green", "blue"]; colors[0] gives you "red". colors[1] gives you "green".

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal