mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 00:01:37 +08:00
style(SquareRoot.js): Fixed style
This commit is contained in:
@ -7,10 +7,8 @@
|
||||
*/
|
||||
|
||||
function sqrt (num, precision = 10) {
|
||||
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(num)) { throw new TypeError(`Expected a number, received ${typeof num}`) }
|
||||
if (!Number.isFinite(precision)) { throw new TypeError(`Expected a number, received ${typeof precision}`) }
|
||||
let sqrt = 1
|
||||
for (let i = 0; i < precision; i++) {
|
||||
sqrt -= (sqrt * sqrt - num) / (2 * sqrt)
|
||||
|
Reference in New Issue
Block a user