SOURCE

function sqrt() {
    let left = 1.4;
    let right = 1.5;
    let mid = (left + right) / 2;
    let diff = 0.0000000001;
    while(right - left > diff) {
        if(mid * mid > 2) {
            right = mid;
        } else {
            left = mid;
        }
        mid = (left + right) / 2;
    }
    return mid.toFixed(10);
}

console.log(sqrt());
console 命令行工具 X clear

                    
>
console