Browse Source

docs(using-reduce): correct grammar

1124-swap-args-test
davhojt 2 years ago committed by Dav Hojt
parent
commit
61ab6ec47b
  1. 31
      subjects/using-reduce/README.md

31
subjects/using-reduce/README.md

@ -2,33 +2,24 @@
### Instructions ### Instructions
Create three functions : Create the following functions:
- `adder` that receives an array and adds its elements. > Your solutions **must** use `reduce`.
- `sumOrMul` that receives an array and adds or multiplies its elements - `adder`: accepts an array of numbers, and returns the sum as a `number`.
depending on whether the element is an odd or an even number, where:
- even = multiply
- odd = add
- `funcExec` that receives an array of functions and executes them. - `sumOrMul`: accepts an array of numbers and adds or multiplies its elements depending on whether the element is odd or even. Even = multiply. Odd = add.
All functions may or may not receive an extra argument that should be the - `funcExec`: accepts an array of functions and executes them using `reduce`, returning the result.
initial value for the functions execution.
Example: > Each function may accept an optional argument, which should be the initial value for the function's execution.
```js #### Example:
sumOrMul([1, 2, 3, 5, 8], 5)
// -> ((((5 + 1) * 2) + 3) + 5) * 8
// -> 160
````
#### Special instruction
The goal of this exercise is to learn to use `reduce`, as such all your ```js
solution **MUST** use `reduce` sumOrMul([1, 2, 3, 5, 8], 5) // (((((5 + 1) * 2) + 3) + 5) * 8) -> 160
```
### Notions ### Notions
- [devdocs.io/javascript/global_objects/array/reduce](https://devdocs.io/javascript/global_objects/array/reduce) - [Array.prototype.reduce](https://devdocs.io/javascript/global_objects/array/reduce)

Loading…
Cancel
Save