← Back to Programming Fundamentals
11

Arrays and Lists: Keeping Related Values in One Structure

Learn to use arrays to group several values, access them by position, and walk through simple lists using the foundation you already built with loops and variables.

📘 Theory

Why an Array Solves a Real Problem

When you have several values of the same family, an array is much healthier than a pile of separate variables.

1

If you want to keep three tasks, you could create `task1`, `task2`, and `task3`. But that becomes awkward as soon as the list grows or changes.

2

An array lets you gather those values in one structure and treat them as an ordered list.

Creating a Simple List

At this stage, small and readable arrays are enough. You do not need advanced methods yet.

Positions and Indexes: Reading a Specific Element

Every value in an array sits in a numbered position called an index.

1

In JavaScript, the first element starts at index `0`. That can feel strange at first, but it is worth learning early because it appears constantly later.

2

This is also an important mental shift: you stop guessing variable names and start reading positions inside a structure.

Loop Through an Array with a `for` Loop

The combination of arrays and loops is one of the first genuinely powerful tools in the course.

🧪 Learn by doing

Example Guided Example: A List of Scores Group several scores into one array and read a specific position.

🏁 Challenges

Challenge Challenge: Create and Loop Through a Task List Declare an array with three tasks and loop through it to show each one in the console.

🧰 Resources

Test

Check your knowledge with a test about Programming Fundamentals.

Test for Programming Fundamentals

What is this?

I'm Cristian Eslava and I sometimes build websites so both you and I can learn and experiment. culTest

I made this in February 2026 to make learning easier for my students. The idea is to learn web development by practicing and to keep expanding the project with new topics, tests and challenges.

It draws inspiration from MDN, W3Schools, CodePen, Manz and many other web development references. I wanted to combine useful theory, runnable examples, challenges and the testing system I had already built for culTest. culTest

If you liked it, if you didn't, or if you want to get in touch, write to me at cristianeslava@gmail.com