diff --git a/src/index.js b/src/index.js index 9d36eb1d..545bf721 100644 --- a/src/index.js +++ b/src/index.js @@ -39,6 +39,7 @@ import isFunction from './is-function' import isOdd from './is-odd' import isNumeric from './is-numeric' import max from './max' +import isPair from './is-pair' export { isOdd, @@ -82,4 +83,5 @@ export { subtraction, isNumeric, max, + isPair, } diff --git a/src/is-pair.js b/src/is-pair.js new file mode 100644 index 00000000..689ad6fb --- /dev/null +++ b/src/is-pair.js @@ -0,0 +1,14 @@ +export default isPair + +/** + * Original Source: + * https://stackoverflow.com/questions/5016313/how-to-determine-if-a-number-is-odd-in-javascript + * + * This method will check if a number is odd or not. + * + * @param {Number} value - value to check + * @return {Boolean} - True if n is pair, false if not + */ +function isPair(value) { + return value % 2 === 0 +} diff --git a/test/is-pair.test.js b/test/is-pair.test.js new file mode 100644 index 00000000..26ae8846 --- /dev/null +++ b/test/is-pair.test.js @@ -0,0 +1,16 @@ +import test from 'ava' +import {isPair} from '../src' + +test('checks if number is pair and returns true', t => { + const n = 20 + const expected = true + const actual = isPair(n) + t.deepEqual(actual, expected) +}) + +test('checks if number is pair and returns false', t => { + const n = 25 + const expected = false + const actual = isPair(n) + t.deepEqual(actual, expected) +})