Skip to content

Commit

Permalink
feat(ch10): add sum reducer
Browse files Browse the repository at this point in the history
  • Loading branch information
poulzinho committed Jan 23, 2020
1 parent 01e62e0 commit fa2396d
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,11 @@ describe("Abstraction and Composition", () => {

expect(doubleAll([1, 4, 8])).to.deep.equal([2, 8, 16]);
});

it("should use a reducer to sum all terms", () => {
const sumReducer = (acc, n) => acc + n;
const terms = [2, 4, 5];

expect(terms.reduce(sumReducer, 0)).to.equal(11);
})
});

0 comments on commit fa2396d

Please sign in to comment.