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

Commit

Permalink
feat: add a feature to find square roots (#84)
Browse files Browse the repository at this point in the history
a new feature/function which help to calculate the square root of any number given as input to it

Closes #83
  • Loading branch information
sinahwz authored and Kent C. Dodds committed Apr 23, 2017
1 parent 1a2be2c commit 67ef2b4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import square from './square'
import sum from './sum'
import dec2bin from './dec2bin'
import searchAndReplace from './search-and-replace'
import sqrt from './sqrt'

export {
initArray,
Expand Down Expand Up @@ -53,4 +54,5 @@ export {
sum,
dec2bin,
searchAndReplace,
sqrt,
}
12 changes: 12 additions & 0 deletions src/sqrt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default sqrt

/**
* This method will perform square root operation.
*
* @param {Number} num - number to calculate its square root
* @return {Number} - Result of the square root operation
*/

function sqrt(num) {
return Math.sqrt(num)
}
10 changes: 10 additions & 0 deletions test/sqrt.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import test from 'ava'
import {sqrt} from '../src'

test('Square root of a number', t => {
const number = 25
const expected = 5
const actual = sqrt(number)
t.deepEqual(actual, expected)
})

0 comments on commit 67ef2b4

Please sign in to comment.