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

Commit568763d

Browse files
committed
[fix] Style changes
1 parent2d342dc commit568763d

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

‎Maths/ParityOutlier.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@
88
*/
99
constparityOutlier=(integers)=>{
1010
// define new containers
11-
letodds=[];//store odd number(s)
12-
letevens=[];// store even number(s)
11+
constodds=[]//store odd number(s)
12+
constevens=[]// store even number(s)
1313

1414
for(leti=0;i<integers.length;i++){
1515
if(!Number.isInteger(integers[i])){// detect non-integer elements
16-
returnnull;
16+
returnnull
1717
}elseif(integers[i]%2===0){// an even number
18-
evens.push(integers[i]);
18+
evens.push(integers[i])
1919
}else{// an odd number
20-
odds.push(integers[i]);
20+
odds.push(integers[i])
2121
}
2222
}
2323

24-
if(odds.length===0||evens.length===0)returnnull;
24+
if(odds.length===0||evens.length===0)returnnull
2525

26-
returnodds.length===1 ?odds[0] :evens[0];
26+
returnodds.length===1 ?odds[0] :evens[0]
2727
}
2828

29-
export{parityOutlier};
29+
export{parityOutlier}

‎Maths/test/ParityOutlier.test.js

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
1-
import{parityOutlier}from"../ParityOutlier";
1+
import{parityOutlier}from'../ParityOutlier'
22

33
describe('Testing parityOutlier function',()=>{
4-
54
it('should return the odd number in an array of even numbers',()=>{
6-
expect(parityOutlier([1,2,16,-8848,5126])).toBe(1);
7-
});
5+
expect(parityOutlier([1,2,16,-8848,5126])).toBe(1)
6+
})
87

98
it('should return the even number in an array of odd numbers',()=>{
10-
expect(parityOutlier([177,5,76,1919])).toBe(76);
11-
});
9+
expect(parityOutlier([177,5,76,1919])).toBe(76)
10+
})
1211

1312
it('should, if the given array has only one integer element, return the integer itself',()=>{
14-
expect(parityOutlier([83])).toBe(83);
15-
expect(parityOutlier([54])).toBe(54);
16-
});
13+
expect(parityOutlier([83])).toBe(83)
14+
expect(parityOutlier([54])).toBe(54)
15+
})
1716

1817
it('should, if the given array has only an odd and an even number, return the odd outlier',()=>{
19-
expect(parityOutlier([1,2])).toBe(1);
20-
expect(parityOutlier([4,3])).toBe(3);
21-
});
18+
expect(parityOutlier([1,2])).toBe(1)
19+
expect(parityOutlier([4,3])).toBe(3)
20+
})
2221

2322
it('should return null if the given array is empty, contains only one integer, contains non-interger elements or does not have a parity outlier',()=>{
24-
expect(parityOutlier([])).toBe(null);
25-
expect(parityOutlier([2])).toBe(null);
26-
expect(parityOutlier([2,{},5,'GitHub'])).toBe(null);
27-
expect(parityOutlier([1,3,5,7,9])).toBe(null);
28-
expect(parityOutlier([0,2,4,6,8])).toBe(null);
29-
});
30-
});
23+
expect(parityOutlier([])).toBe(null)
24+
expect(parityOutlier([2])).toBe(null)
25+
expect(parityOutlier([2,{},5,'GitHub'])).toBe(null)
26+
expect(parityOutlier([1,3,5,7,9])).toBe(null)
27+
expect(parityOutlier([0,2,4,6,8])).toBe(null)
28+
})
29+
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp