--- id: 5d7925395888767e9304c082 title: Part 119 challengeType: 0 --- ## Description
The `reduce` method takes a function with an accumulator and the current value. The accumulator is initially set to the value at index 0. The `reduce` method then goes through each element of the array after that, passing in the element as the current value and the result of the last call as the accumulator. For example, here's how to multiply all the value in an array: ```js [2, 3, 4].reduce((a, x) => a * x); // 24 ``` Using `reduce`, add a function `sum` to `spreadsheetFunctions`, which sums all values in the array passed to it.
## Instructions
## Tests
```yml tests: - text: See description above for instructions. testString: assert(spreadsheetFunctions.sum([10,5,1,3]) === 19 && code.includes("reduce")); ```
## Challenge Seed
```html ```
### Before Test
```html Spreadsheet
```
### After Test
```html ```
## Solution
```html ```