mirror of https://github.com/01-edu/public.git
docs(reduce): fix inconsistency in the number of functions
This commit is contained in:
parent
c0792d627f
commit
4e13857c4d
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
### Instructions
|
### Instructions
|
||||||
|
|
||||||
Create three functions:
|
Create four functions:
|
||||||
|
|
||||||
- `fold` that receives an array, a function and an accumulator, in this order,
|
- `fold` that receives an array, a function and an accumulator, in this order,
|
||||||
and applies the function in the elements of the array starting on the left.
|
and applies the function in the elements of the array starting on the left.
|
||||||
|
@ -25,6 +25,7 @@ const adder = (a, b) => a + b
|
||||||
fold([1, 2, 3], adder, 2) // returns 8 (2 + 1 + 2 + 3)
|
fold([1, 2, 3], adder, 2) // returns 8 (2 + 1 + 2 + 3)
|
||||||
foldRight([1, 2, 3], adder, 2) // returns 8 (2 + 3 + 2 + 1)
|
foldRight([1, 2, 3], adder, 2) // returns 8 (2 + 3 + 2 + 1)
|
||||||
reduce([1, 2, 3], adder) // returns 6 (1 + 2 + 3)
|
reduce([1, 2, 3], adder) // returns 6 (1 + 2 + 3)
|
||||||
|
reduceRight([1, 2, 3], adder) // returns 6 (3 + 2 + 1)
|
||||||
```
|
```
|
||||||
|
|
||||||
The use of `[].reduce` and `[].reduceRight` is forbidden for this exercise.
|
The use of `[].reduce` and `[].reduceRight` is forbidden for this exercise.
|
||||||
|
|
Loading…
Reference in New Issue