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

Commit 10eb532

Browse files
jsinaKent C. Dodds
authored andcommitted
feat: add subtraction (#106)
* WIP: subtract two number * add test for subtract method * modify index file * modify test
1 parent 0f7621e commit 10eb532

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

src/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import startsWith from './startsWith'
2020
import removeDuplicates from './remove-duplicates'
2121
import add from './add'
2222
import subtract from './subtract'
23+
import subtraction from './subtraction'
2324
import divide from './divide'
2425
import multiply from './multiply'
2526
import square from './square'
@@ -74,4 +75,6 @@ export {
7475
round,
7576
checkPalindrome,
7677
isFunction,
78+
subtraction,
7779
}
80+

src/subtraction.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export default subtraction
2+
3+
/**
4+
*
5+
* This method will return a random integer
6+
* between min and max number
7+
*
8+
* @param {Number} num1 - The first number to be subtracted
9+
* @param {Number} max - The second number to subtract from
10+
* @return {Number} the subtraction of num1 - num2
11+
*/
12+
13+
function subtraction(num1, num2) {
14+
return num1 - num2
15+
}

test/subtract.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import test from 'ava'
2+
import subtraction from '../src/subtraction'
3+
4+
test('Subtracts two integers ', t => {
5+
const number1 = 23
6+
const number2 = 3
7+
const expected = 23 - 3
8+
const actual = subtraction(number1, number2)
9+
t.deepEqual(actual, expected)
10+
})

0 commit comments

Comments
 (0)