James McGrath

Quick tips, in-depth guides, and thoughts on the future of the web

What Is an Array?

🧪 Concept:
An array is a list. That’s it! It’s like a row of boxes, each holding something. Could be numbers, words, or even other arrays.

In JavaScript:

let groceries = ["milk", "bread", "eggs"];

You just made a list with three things. You can access each item by its position (starting from 0):

console.log(groceries[0]); // milk

🧰 Why It Matters:
Arrays help you group related things and work with them efficiently. Loops and functions often team up with arrays for powerful effects.

🎉 Quick Challenge:
Make an array with:
▪ Your 3 favourite foods
▪ Log the second one to the console

Example:

let favorites = ["pizza", "sushi", "tacos"];
console.log(favorites[1]); // sushi

🧠 Fun Analogy:
Imagine a train with labelled cars. Each car holds something — and you can hop on the one you need by number. That’s an array.

📚 Further Reading:
MDN Docs – if...else
W3Schools – JavaScript Conditions

Join us tomorrow for Day 4!

Subscribe to my feed to follow along. I’ll keep the lessons short and sweet.

What Is a Function?

One response to “What Is an Array?”

  1. […] What is an Array? […]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.