--- id: 5ddb965c65d27e1512d44dad title: Part 20 challengeType: 0 --- # --description-- Let's says we have an array `[1, 3, 5]` named `arr` and we want to sum up all the numbers. We can use the reduce function as follows: ```js arr.reduce((accumulator, currentValue) => { return accumulator + currentValue; }, 0); ``` At `arr[0]`, the function is `(0, 1) => { return 0 + 1 }`, since `arr[0] = 1 = currentValue`. At `arr[1]`, the function is `(1, 3) => 1 + 3`, Finally at `arr[2]`, the function is `(4, 5) => 4 + 5`. Now the accumulator is `9` and since we have gone through all of the items in `arr`, the `reduce()` method will return `9`. In the body of the callback function, replace `/* code to run */` with `return accumulator + currentValue`. # --hints-- See description above for instructions. ```js assert( code .replace(/\s/g, '') .match( /reduce\(\(accumulator\,currentValue\)\=\>{returnaccumulator\+currentValue\;?},0\)/ ) ); ``` # --seed-- ## --before-user-code-- ```html

Calorie Counter

Sex
Breakfast
Lunch
Dinner
``` ## --after-user-code-- ```html ``` ## --seed-contents-- ```html ``` # --solutions-- ```html ```