Skip to content

Commit

Permalink
Adding sum func
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-codecov committed Nov 26, 2024
1 parent 81fa212 commit db3f9e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions flag1/mafs.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ function divide(a, b) {
}
}

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

module.exports = { add, subtract, multiply, divide };
module.exports = { add, subtract, multiply, divide, sum };
8 changes: 4 additions & 4 deletions flag1/mafs.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { add, subtract, multiply, divide } = require("./mafs");
const { add, subtract, multiply, divide, sum } = require("./mafs");

test("adds 1 + 2 to equal 3", () => {
expect(add(1, 2)).toBe(3);
Expand All @@ -20,6 +20,6 @@ test('divides 8 / 2 to equal 4', () => {
expect(divide(8, 2)).toBe(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(1, 2, 3, 4)).toBe(10);
});

0 comments on commit db3f9e4

Please sign in to comment.