--- id: 5ddb965c65d27e1512d44dad title: Part 20 challengeType: 0 isHidden: true --- ## 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`.
## Instructions
## Tests
```yml tests: - text: See description above for instructions. testString: assert( code.replace(/\s/g, '').match(/reduce\(\(accumulator\,currentValue\)\=\>{returnaccumulator\+currentValue\;?},0\)/) ); ```
## Challenge Seed
```html ```
### Before Test
```html

Calorie Counter

Sex
Breakfast
Lunch
Dinner
```
### After Test
```html ```
## Solution
```html ```