Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a22c048 commit 2c1052dCopy full SHA for 2c1052d
1 file changed
Maths/SquareRoot.js
@@ -7,6 +7,10 @@
7
*/
8
9
function sqrt (num, precision = 10) {
10
+ if (!Number.isFinite(num))
11
+ throw new TypeError(`Expected a number, received ${typeof num}`)
12
+ if (!Number.isFinite(precision))
13
+ throw new TypeError(`Expected a number, received ${typeof precision}`)
14
let sqrt = 1
15
for (let i = 0; i < precision; i++) {
16
sqrt -= (sqrt * sqrt - num) / (2 * sqrt)
0 commit comments