This repository has been archived by the owner on Feb 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 603
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a feature to find square roots (#84)
a new feature/function which help to calculate the square root of any number given as input to it Closes #83
- Loading branch information
Showing
3 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) | ||
|