Arrays
An array holds an ordered list. Indexes start at 0. Useful methods: push, pop, map, filter and includes.
map transforms every item. filter keeps only the items that pass a test.
Example
const nums = [1, 2, 3, 4, 5];
nums.push(6);
console.log(nums.length);
console.log(nums[0]);
console.log(nums.map((n) => n * 10));
console.log(nums.filter((n) => n % 2 === 0));Exercise
Add an item to the end of the array.
const fruits = ["apple"]; fruits.("mango");
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.