Skip to content

Commit

Permalink
Sum 0 test
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-codecov committed Nov 27, 2024
1 parent db3f9e4 commit 13a8b08
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions flag1/mafs.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function divide(a, b) {
}

function sum(...args) {
if (args.length === 0) return 0;
return args.reduce((acc, curr) => acc + curr, 0);
}

Expand Down
4 changes: 4 additions & 0 deletions flag1/mafs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ test('divides 8 / 2 to equal 4', () => {
test('sums 1 + 2 + 3 + 4 to equal 10', () => {
expect(sum(1, 2, 3, 4)).toBe(10);
});

test('sums 1 + 2 + 3 + 4 to equal 10', () => {
expect(sum()).toBe(0);
});

0 comments on commit 13a8b08

Please sign in to comment.