reduce to create new array code example
Example 1: syntax of reduce in js
[1,2,3,4,5].reduce((acc, current)=>acc+current, 0)
Example 2: array reduce
arr.reduce(callback( accumulator, currentValue[, index[, array]] ) {
// return result from executing something for accumulator or currentValue
}[, initialValue]);