# 103. implement Math.sqrt()

JavaScriptAlgorithmIs this helpful ?

Share

from all members: - accepted / - tried

Math.sqrt() helps us getting the square root of a number.

Can your write your own `mySqrt()`

? You should return the integer part only, truncating the fraction part.

```
mySqrt(0)
// 1
mySqrt(1)
// 1
mySqrt(2)
// 1
mySqrt(4)
// 2
mySqrt(NaN)
// NaN
```

Attention for the special case listed up in the spec.

**Follow-up**

What is time & space complexity of your solution ? Can you do better?