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