Tsallaka zuwa abun ciki
Justice Tech School

Array Methods

map, filter, reduce, find, some, every, sort and flat are the daily tools.

Example
const n = [5, 2, 8, 1];
console.log(n.map((x) => x * 2), n.filter((x) => x > 2), n.reduce((s, x) => s + x, 0));
console.log(n.find((x) => x > 5), n.some((x) => x > 7), [...n].sort((a, b) => a - b));

Result

[ 10, 4, 16, 2 ] [ 5, 8 ] 16
8 true [ 1, 2, 5, 8 ]

Exercise

Filter items.

n.((x) => x > 2)

Quiz Test

What does reduce return?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.