Skip to content

Commit 94704c0

Browse files
All test cases pass for infinite Division operation
1 parent 3882669 commit 94704c0

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

operations/operations.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const subtract = function(a, b) {
2323
return typeof a === "number" && typeof b === "number" ? a - b : false;
2424
};
2525

26+
//Multiplication Operation
2627
const multiply = function() {
2728
let total = 1;
2829
for (let arg in arguments) {
@@ -37,4 +38,9 @@ const multiply = function() {
3738
return total;
3839
};
3940

40-
module.exports = { add, addAll, subtract, multiply };
41+
//DIvision Operation
42+
const divide = function (a, b) {
43+
return typeof a === "number" && typeof b === "number" ? a / b : false;
44+
}
45+
46+
module.exports = { add, addAll, subtract, multiply, divide };

operations/operations.test.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { add, addAll, subtract, multiply } = require("./operations");
1+
const { add, addAll, subtract, multiply, divide } = require("./operations");
22

33
//Testing Add implementation
44
describe("Testing Add implementation", () => {
@@ -37,7 +37,7 @@ describe("Testing Subbtaction implementation", () => {
3737
it("Subtraction of 23 and 50", () => {
3838
expect(subtract(23, 50)).toBe(-27);
3939
});
40-
it("Subtraction of 21 and 111", () => {
40+
it("Subtraction of 111 and 21", () => {
4141
expect(subtract(111, 21)).toBe(90);
4242
});
4343
it("Parameter should only be Numbers", () => {
@@ -50,10 +50,10 @@ describe("Testing Multiply implimentation", () => {
5050
it("Multiplication of 4 and 4", () => {
5151
expect(multiply(4, 4)).toBe(16);
5252
});
53-
it("Multiplication of 1 and 1", () => {
53+
it("Multiplication of many numbers", () => {
5454
expect(multiply(1, 1, 2, 3, 4)).toBe(24);
5555
});
56-
it("Multiplication of 1 and 1", () => {
56+
it("Multiplication of 11 and -8", () => {
5757
expect(multiply(11, -8)).toBe(-88);
5858
});
5959
it("Multiplication of 1132 and 1131331", () => {
@@ -65,4 +65,17 @@ describe("Testing Multiply implimentation", () => {
6565
}
6666
expect(logError).toThrowError(Error);
6767
});
68-
});
68+
});
69+
70+
//Testing Division implementation
71+
describe("Testing Division implementation", () => {
72+
it("Subtraction of 1 and 2", () => {
73+
expect(divide(1, 2)).toBe(0.5);
74+
});
75+
it("Subtraction of 100 and 25", () => {
76+
expect(divide(100, 25)).toBe(4);
77+
});
78+
it("Parameter should only be Numbers", () => {
79+
expect(divide(3, "4")).toBeFalsy();
80+
});
81+
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy