From db3f9e4d54f678277adbac0301e05f3d6fa63da7 Mon Sep 17 00:00:00 2001 From: Tony Le Date: Tue, 26 Nov 2024 16:29:13 -0500 Subject: [PATCH] Adding sum func --- flag1/mafs.js | 8 ++++---- flag1/mafs.test.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/flag1/mafs.js b/flag1/mafs.js index 4a9f43b..51c234a 100644 --- a/flag1/mafs.js +++ b/flag1/mafs.js @@ -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 }; diff --git a/flag1/mafs.test.js b/flag1/mafs.test.js index 2d37cb8..a7179d5 100644 --- a/flag1/mafs.test.js +++ b/flag1/mafs.test.js @@ -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); @@ -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); +});