-
Notifications
You must be signed in to change notification settings - Fork 0
JavaScript
kitiya edited this page Mar 6, 2020
·
4 revisions
const nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
const double = nums.map(num => num * 2); // [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]const fiveUp = nums.filter(num => num >= 5); // [5, 6, 7, 8, 9]Syntax reduce(function, initialValue)
const initialValue = 0;
const total = nums.reduce((accumulator, num) => {return accumulator + num;}, initialValue); // 55