Skip to content
This repository has been archived by the owner on Feb 20, 2019. It is now read-only.

WIP: add new function check number is pair #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -82,4 +83,5 @@ export {
subtraction,
isNumeric,
max,
isPair,
}
14 changes: 14 additions & 0 deletions src/is-pair.js
Original file line number Diff line number Diff line change
@@ -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
}
16 changes: 16 additions & 0 deletions test/is-pair.test.js
Original file line number Diff line number Diff line change
@@ -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)
})