carly31
8/7/2018 - 12:58 AM

map, filter, reduce

let arr = [1,2,3,4];
let sum = arr.reduce((acc, val) => {
  return acc + val;
});
//sum = 10
let arr = [1,2,3,4,5,6];

let even = arr.filter(val => {
  return val % 2 === 0;
});

// even = [2,4,6]
let newArr = oldArr.map((val, index, arr) => {

  // return element to new Array

});