Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c269bac

Browse filesBrowse files
All divide operation test cases pass
1 parent 522f3c9 commit c269bac
Copy full SHA for c269bac

File tree

2 files changed

+12
-2
lines changed
Filter options

2 files changed

+12
-2
lines changed

‎operations/arithmethics/operations.js

Copy file name to clipboardExpand all lines: operations/arithmethics/operations.js
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ const multiply = function() {
4848

4949
//Division Operation
5050
const divide = function(a, b) {
51-
return typeof a === "number" && typeof b === "number" ? a / b : false;
51+
return arguments.length < 2 || arguments.length > 3
52+
? "Input only two Numbers"
53+
: typeof a === "number" && typeof b === "number"
54+
? a / b
55+
: "Inputs Must be Numbers";
5256
};
5357

5458
//String Concatenation Operation

‎operations/arithmethics/operations.test.js

Copy file name to clipboardExpand all lines: operations/arithmethics/operations.test.js
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,13 @@ describe("Testing Division implementation", () => {
9292
expect(divide(100, 25)).toBe(4);
9393
});
9494
it("Parameter should only be Numbers", () => {
95-
expect(divide(3, "4")).toBeFalsy();
95+
expect(divide(3, "4")).toMatch(/Must be Numbers/);
96+
});
97+
it("Parameter should at least be two", () => {
98+
expect(divide(3)).toMatch(/only two Numbers/);
99+
});
100+
it("Parameter should not be more than two", () => {
101+
expect(divide(3, 3, 3, 4)).toMatch(/only two Numbers/);
96102
});
97103
});
98104

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.