An animated guide to Array Reduce
This is an example of an animated guide to Array Reduce
Sum an array
JS
Sum an array with Reduce
Step 0/9
let numbers = [11, 2, 3, 4, 5, 6, 7, 8, 9]numbers.reduce((sum, number) => {return sum + number}, 00)
Get the element with the greatest value
JS
Find the greatest value with reduce
Step 0/6
let numbers = [22, 0, 15, 11, 3, 14]numbers.reduce((max, number) => {return max > number? max: number}, 00)