Learn to Code
All tracks
Learn to Code

Free lessons from scratch to pro — every language, databases and DevOps.

AboutContactPrivacy PolicyTerms of Use

Your progress is saved in this browser. © 2026 Learn to Code

JS
JavaScript
0/12 completed
Beginner
What is JavaScript?Variables and data typesOperators and expressionsMaking decisions: if and switchLoops
Intermediate
FunctionsArrays and array methodsObjects
Advanced
Scope and closuresClasses and OOPPromises and async/await
Pro
The event loop
Tracks / JavaScript / Intermediate

Arrays and array methods

An array is an ordered list of values. Shopping carts, search results, chat messages and leaderboards are all arrays.

Creating and reading arrays

JavaScript · editable

Adding and removing

JavaScript · editable

The big three: map, filter, reduce

These methods take a callback function and return a new array or value. They don't change the original. Professional JavaScript uses them constantly.

JavaScript · editable

reduce takes two arguments: a function (accumulator, item) => newAccumulator and a starting value (0 above).

Chaining

Because each method returns a new array, you can chain them into a pipeline:

JavaScript · editable

More useful methods

JavaScript · editable

Sorting numbers: [10, 9, 1].sort() gives [1, 10, 9] because the default sort compares items as strings. Always pass a compare function: .sort((a, b) => a - b).

Spread and destructuring

JavaScript · editable

Practice

Given a list of students, print the names of those who passed (score ≥ 50), sorted from highest score to lowest, and the class average.

JavaScript · editable
✎ Check your understanding

1.What does [1, 2, 3].map(n => n * 2) return?

2.Which method returns a single value built from all items?

← Functions