Creating arrays
Arrays are used to store multiple values in a single variable.
Learning Goals
The Core Concept
An array is a special variable that can hold more than one value at a time. Think of it as a list of items.
You can store strings, numbers, objects, or even other arrays inside an array. Arrays are zero-indexed, which means the first item is at position 0, the second is at position 1, and so on.
Visual guide
JavaScript concept flow
A simple original diagram to connect the lesson idea with real project flow.
Code & Implementation
// Creating an array
const fruits = ["Apple", "Banana", "Cherry"];
// Accessing the first item (Index 0)
console.log(fruits[0]); // Apple
// Adding an item to the end
fruits.push("Mango");
// Finding the length of the array
console.log("Total fruits: " + fruits.length);Expected Output
Apple Total fruits: 4
Practical Project: Creating arrays Implementation
Hands-on practice task
The Challenge
Apply your knowledge of Creating arrays to build a real-world feature. This project helps you move beyond theory and understand how JavaScript works in professional settings.
Helpful Hints
- •Refer back to the 'Steps' section for the correct sequence.
- •Check the 'Tips' for common optimization patterns.
- •Look at the 'Code Highlights' to ensure you're using the right syntax.
Quick Knowledge Check
If I use 'const' for an array, how can I add items to it?
Continue Learning
Next steps after this lesson
Apply your knowledge of Creating arrays to build a real-world feature. This project helps you move beyond theory and understand how JavaScript works in professional settings.
Ready to put your coding skills to the test?
Don't just read—write code! Use our free Try-Code Playground to experiment with real-time preview, or search utilities on our Developer Tools List.