Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit7c4bc1e

Browse files
Merge pull request#2 from iKnowJavaScript/develop
Develop
2 parents4288e16 +807bdc5 commit7c4bc1e

File tree

16 files changed

+193
-233
lines changed

16 files changed

+193
-233
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports=functionaddAll(){
2+
if(arguments.length<2)return"Input at least two Number";
3+
4+
lettotal=0;
5+
for(letarginarguments){
6+
letloop=typeofarguments[arg]==="number";
7+
8+
if(!loop){
9+
thrownewError("Only Numbers are allowed");
10+
}else{
11+
total+=arguments[arg];
12+
}
13+
}
14+
returntotal;
15+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
constaddAll=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(/leasttwoNumber/);
12+
});
13+
it("Parameter should only be Numbers",()=>{
14+
functionlogError(){
15+
addAll([],2,3,4,5,6,7,8,8,9,10);
16+
}
17+
expect(logError).toThrowError(Error);
18+
});
19+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports=functionjoinString(a,b){
2+
returnarguments.length<2||arguments.length>3
3+
?"Input only two String"
4+
:typeofa==="string"&&typeofb==="string"
5+
?a.concat(b)
6+
:"Inputs Must be String";
7+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
constjoinString=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(/MustbeString/);
12+
});
13+
it("Parameter should at least be two",()=>{
14+
expect(joinString("Well")).toMatch(/onlytwoString/);
15+
});
16+
it("Parameter should not be more than two",()=>{
17+
expect(joinString("Good","Job","Well","Done")).toMatch(/onlytwoString/);
18+
});
19+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports=functiondivide(a,b){
2+
returnarguments.length<2||arguments.length>3
3+
?"Input only two Numbers"
4+
:typeofa==="number"&&typeofb==="number"
5+
?a/b
6+
:"Inputs Must be Numbers";
7+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
constdivide=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(/MustbeNumbers/);
12+
});
13+
it("Parameter should at least be two",()=>{
14+
expect(divide(3)).toMatch(/onlytwoNumbers/);
15+
});
16+
it("Parameter should not be more than two",()=>{
17+
expect(divide(3,3,3,4)).toMatch(/onlytwoNumbers/);
18+
});
19+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports=functionmultiply(){
2+
3+
if(arguments.length<2)return"Input at least two Number";
4+
5+
lettotal=1;
6+
for(letarginarguments){
7+
letloop=typeofarguments[arg]==="number";
8+
9+
if(!loop){
10+
thrownewError("Only Numbers are allowed");
11+
}else{
12+
total*=arguments[arg];
13+
}
14+
}
15+
returntotal;
16+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
constmultiply=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(/leasttwoNumber/);
18+
});
19+
it("All parameter should only be Numbers",()=>{
20+
functionlogError(){
21+
multiply([],2,3,4,5,6,7,8,8,9,10);
22+
}
23+
expect(logError).toThrowError(Error);
24+
});
25+
});

‎operations/arithmethics/operations.js‎

Lines changed: 0 additions & 74 deletions
This file was deleted.

‎operations/arithmethics/operations.test.js‎

Lines changed: 0 additions & 128 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp