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 7c4bc1e

Browse filesBrowse files
Merge pull request #2 from iKnowJavaScript/develop
Develop
2 parents 4288e16 + 807bdc5 commit 7c4bc1e
Copy full SHA for 7c4bc1e

File tree

16 files changed

+193
-233
lines changed
Filter options

16 files changed

+193
-233
lines changed
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = function addAll() {
2+
if(arguments.length < 2) return "Input at least two Number";
3+
4+
let total = 0;
5+
for (let arg in arguments) {
6+
let loop = typeof arguments[arg] === "number";
7+
8+
if (!loop) {
9+
throw new Error("Only Numbers are allowed");
10+
} else {
11+
total += arguments[arg];
12+
}
13+
}
14+
return total;
15+
};
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const addAll = require("./addAll");
2+
3+
describe("Testing add operation for Infinite numbers", () => {
4+
it("Addition of 1 and 1 equals 2", () => {
5+
expect(addAll(1, 1)).toBe(2);
6+
});
7+
it("Addition of multiple value", () => {
8+
expect(addAll(11, 2, 3, 4, 5, 6, 7, 8, 8, 9, 10)).toBe(73);
9+
});
10+
it("Parameter should at least be two", () => {
11+
expect(addAll()).toMatch(/least two Number/);
12+
});
13+
it("Parameter should only be Numbers", () => {
14+
function logError() {
15+
addAll([], 2, 3, 4, 5, 6, 7, 8, 8, 9, 10);
16+
}
17+
expect(logError).toThrowError(Error);
18+
});
19+
});
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = function joinString (a, b) {
2+
return arguments.length < 2 || arguments.length > 3
3+
? "Input only two String"
4+
: typeof a === "string" && typeof b === "string"
5+
? a.concat(b)
6+
: "Inputs Must be String";
7+
};
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const joinString = require("./joinString")
2+
3+
describe("Testing String Concatenation implementation", () => {
4+
it('Concatenate of "Well" and "Done"', () => {
5+
expect(joinString("Well", "Done")).toBe("WellDone");
6+
});
7+
it('Concatenate of "Good" and "Job"', () => {
8+
expect(joinString("Good", "Job")).toBe("GoodJob");
9+
});
10+
it("Parameter should only be String", () => {
11+
expect(joinString("Well", 4)).toMatch(/Must be String/);
12+
});
13+
it("Parameter should at least be two", () => {
14+
expect(joinString("Well")).toMatch(/only two String/);
15+
});
16+
it("Parameter should not be more than two", () => {
17+
expect(joinString("Good", "Job", "Well", "Done")).toMatch(/only two String/);
18+
});
19+
});
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = function divide (a, b) {
2+
return arguments.length < 2 || arguments.length > 3
3+
? "Input only two Numbers"
4+
: typeof a === "number" && typeof b === "number"
5+
? a / b
6+
: "Inputs Must be Numbers";
7+
};
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const divide = require("./divide");
2+
3+
describe("Testing Division implementation", () => {
4+
it("Subtraction of 1 and 2", () => {
5+
expect(divide(1, 2)).toBe(0.5);
6+
});
7+
it("Subtraction of 100 and 25", () => {
8+
expect(divide(100, 25)).toBe(4);
9+
});
10+
it("Parameter should only be Numbers", () => {
11+
expect(divide(3, "4")).toMatch(/Must be Numbers/);
12+
});
13+
it("Parameter should at least be two", () => {
14+
expect(divide(3)).toMatch(/only two Numbers/);
15+
});
16+
it("Parameter should not be more than two", () => {
17+
expect(divide(3, 3, 3, 4)).toMatch(/only two Numbers/);
18+
});
19+
});
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = function multiply() {
2+
3+
if(arguments.length < 2) return "Input at least two Number";
4+
5+
let total = 1;
6+
for (let arg in arguments) {
7+
let loop = typeof arguments[arg] === "number";
8+
9+
if (!loop) {
10+
throw new Error("Only Numbers are allowed");
11+
} else {
12+
total *= arguments[arg];
13+
}
14+
}
15+
return total;
16+
};
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const multiply = require("./multiply")
2+
3+
describe("Testing Multiply implimentation for infinite number", () => {
4+
it("Multiplication of 4 and 4", () => {
5+
expect(multiply(4, 4)).toBe(16);
6+
});
7+
it("Multiplication of many numbers", () => {
8+
expect(multiply(1, 1, 2, 3, 4)).toBe(24);
9+
});
10+
it("Multiplication of 11 and -8", () => {
11+
expect(multiply(11, -8)).toBe(-88);
12+
});
13+
it("Multiplication of 1132 and 1131331", () => {
14+
expect(multiply(1132, 1131331)).toBe(1280666692);
15+
});
16+
it("Parameter should at least be two", () => {
17+
expect(multiply(1)).toMatch(/least two Number/);
18+
});
19+
it("All parameter should only be Numbers", () => {
20+
function logError() {
21+
multiply([], 2, 3, 4, 5, 6, 7, 8, 8, 9, 10);
22+
}
23+
expect(logError).toThrowError(Error);
24+
});
25+
});

‎operations/arithmethics/operations.js

Copy file name to clipboardExpand all lines: operations/arithmethics/operations.js
-74Lines changed: 0 additions & 74 deletions
This file was deleted.

‎operations/arithmethics/operations.test.js

Copy file name to clipboardExpand all lines: operations/arithmethics/operations.test.js
-128Lines changed: 0 additions & 128 deletions
This file was deleted.
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = function subtract (a, b) {
2+
return arguments.length < 2 || arguments.length > 3
3+
? "Input only two Numbers"
4+
: typeof a === "number" && typeof b === "number"
5+
? a - b
6+
: "Inputs Must be Numbers";
7+
};
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const subtract = require("./subtract")
2+
3+
describe("Testing Subbtaction implementation", () => {
4+
it("Subtraction of 1 and 1", () => {
5+
expect(subtract(1, 1)).toBe(0);
6+
});
7+
it("Subtraction of 23 and 50", () => {
8+
expect(subtract(23, 50)).toBe(-27);
9+
});
10+
it("Subtraction of 111 and 21", () => {
11+
expect(subtract(111, 21)).toBe(90);
12+
});
13+
it("Parameter should only be Numbers", () => {
14+
expect(subtract(3, "4")).toMatch(/Must be Numbers/);
15+
});
16+
it("Parameter should at least be two", () => {
17+
expect(subtract(3)).toMatch(/only two Numbers/);
18+
});
19+
it("Parameter should not be more than two", () => {
20+
expect(subtract(3, 3, 3, 4)).toMatch(/only two Numbers/);
21+
});
22+
});
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = function twoSum(a, b) {
2+
return arguments.length < 2 || arguments.length > 3
3+
? "Input only two Numbers"
4+
: typeof a === "number" && typeof b === "number"
5+
? a + b
6+
: "Inputs Must be Numbers";
7+
};

0 commit comments

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