This repository was archived by the owner on Feb 20, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Expand file tree Collapse file tree 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'
3636import round from './round'
3737import checkPalindrome from './checkPalindrome'
3838import isFunction from './is-function'
39+ import isOdd from './is-odd'
3940
4041export {
42+ isOdd ,
4143 isEven ,
4244 revstring ,
4345 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