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

Commit b7dfa21

Browse files
naumicoderKent C. Dodds
authored andcommitted
feat(subtract): Add a "subtract" function (#60)
Closes #56
1 parent 8a8a9d9 commit b7dfa21

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import isNullOrWhitespace from './is-null-or-whitespace'
1414
import startsWith from './startsWith'
1515
import removeDuplicates from './remove-duplicates'
1616
import add from './add'
17+
import subtract from './subtract'
1718

1819
export {
1920
flatten,
@@ -32,4 +33,5 @@ export {
3233
startsWith,
3334
removeDuplicates,
3435
add,
36+
subtract,
3537
}

src/subtract.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export default Subtract
2+
3+
/**
4+
* @module Subtract
5+
* @Description This method will perform Subtract operation.
6+
*
7+
* @param {Number} num1 - first number for Subtraction
8+
* @param {Number} num2 - second number for Subtraction
9+
* @return {Number} - Result of Subtraction
10+
*/
11+
function Subtract(num1, num2) {
12+
return num1 - num2
13+
}

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 {subtract} from '../src'
3+
4+
test('subtract two integers ', t => {
5+
const number1 = 30
6+
const number2 = 12
7+
const expected = 30 - 12
8+
const actual = subtract(number1, number2)
9+
t.deepEqual(actual, expected)
10+
})

0 commit comments

Comments
 (0)