๐Ÿ“˜arr.reduce()

// โญ๏ธ array ---> reduced into a single value
let finalResult = arr.reduce(
  // โญ๏ธ reducer function
  (prevResult, next, i, array) =>  nextResult,
  // โญ๏ธ if initial value not provided, `arr[0]` will be used instead,
  //    iteration will start from `arr[1]`.
  [initialValue]
);

Last updated