This repository was archived by the owner on Feb 20, 2019. It is now read-only.
File tree 3 files changed +32
-0
lines changed
3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -36,8 +36,10 @@ import endsWith from './endsWith'
36
36
import round from './round'
37
37
import checkPalindrome from './checkPalindrome'
38
38
import isFunction from './is-function'
39
+ import isOdd from './is-odd'
39
40
40
41
export {
42
+ isOdd ,
41
43
isEven ,
42
44
revstring ,
43
45
initArray ,
Original file line number Diff line number Diff line change
1
+ export default isOdd
2
+
3
+ /**
4
+ * Original Source:
5
+ * https://stackoverflow.com/questions/5016313/how-to-determine-if-a-number-is-odd-in-javascript
6
+ *
7
+ * This method will check if a number is odd or not.
8
+ *
9
+ * @param {Number } num - number to check
10
+ * @return {Boolean } - True if n is odd, false if not
11
+ */
12
+ function isOdd ( num ) {
13
+ return num % 2 !== 0
14
+ }
Original file line number Diff line number Diff line change
1
+ import test from 'ava'
2
+ import { isOdd } from '../src'
3
+
4
+ test ( 'checks if number is odd and returns true' , t => {
5
+ const n = 27
6
+ const expected = true
7
+ const actual = isOdd ( n )
8
+ t . deepEqual ( actual , expected )
9
+ } )
10
+
11
+ test ( 'checks if number is odd and returns false' , t => {
12
+ const n = 26
13
+ const expected = false
14
+ const actual = isOdd ( n )
15
+ t . deepEqual ( actual , expected )
16
+ } )
You can’t perform that action at this time.
0 commit comments