Skip to content

Commit a3233f5

Browse files
author
Dan Wood
committed
Change complex reduce funciton to clearer map reduce.
1 parent 6741e85 commit a3233f5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ class SuperArray extends Array {
659659

660660
### Favor functional programming over imperative programming
661661
JavaScript isn't a functional language in the way that Haskell is, but it has
662-
a functional flavor to it. Functional languages are cleaner and easier to test.
662+
a functional flavor to it. Functional languages can be cleaner and easier to test.
663663
Favor this style of programming when you can.
664664

665665
**Bad:**
@@ -708,7 +708,8 @@ const programmerOutput = [
708708
const INITIAL_VALUE = 0;
709709

710710
const totalOutput = programmerOutput
711-
.reduce((acc, { linesOfCode }) => acc + linesOfCode, INITIAL_VALUE);
711+
.map(output => output.linesOfCode)
712+
.reduce((totalLines, lines) => totalLines + lines);
712713
```
713714
**[⬆ back to top](#table-of-contents)**
714715

0 commit comments

Comments
 (0)