chore(SquareRoot.js): Better Precision constant

This commit is contained in:
Rak Laptudirm
2021-05-30 17:04:24 +05:30
committed by GitHub
parent 4ed05e2f66
commit a9b1f8994f

View File

@ -6,7 +6,7 @@
* Finding the square root of a number using Newton's method. * Finding the square root of a number using Newton's method.
*/ */
function sqrt (num, precision = 10) { function sqrt (num, precision = 4) {
if (!Number.isFinite(num)) { throw new TypeError(`Expected a number, received ${typeof num}`) } if (!Number.isFinite(num)) { throw new TypeError(`Expected a number, received ${typeof num}`) }
if (!Number.isFinite(precision)) { throw new TypeError(`Expected a number, received ${typeof precision}`) } if (!Number.isFinite(precision)) { throw new TypeError(`Expected a number, received ${typeof precision}`) }
let sqrt = 1 let sqrt = 1