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

Commit e66b6ce

Browse files
shubham808Kent C. Dodds
authored andcommitted
feat: add square function (#65)
* square function * retry
1 parent 7dc7680 commit e66b6ce

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import add from './add'
1717
import subtract from './subtract'
1818
import divide from './divide'
1919
import multiply from './multiply'
20+
import square from './square'
2021

2122
export {
2223
flatten,
@@ -38,4 +39,5 @@ export {
3839
subtract,
3940
divide,
4041
multiply,
42+
square,
4143
}

src/square.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export default square
2+
3+
/**
4+
* This method will perform square of a number.
5+
*
6+
* @param {Number} num1 - number
7+
* @return {Number} - Result of square of a number
8+
*/
9+
function square(num1) {
10+
return num1 * num1
11+
}

test/square.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import test from 'ava'
2+
import {square} from '../src'
3+
4+
test('Square a number ', t => {
5+
const number = 3
6+
const expected = 3 * 3
7+
const actual = square(number)
8+
t.deepEqual(actual, expected)
9+
})

0 commit comments

Comments
 (0)