How to do square root in JavaScript?

To do square root in JavaScript, use the Math.sqrt function like so: Math.sqrt(number).

Here's how you do it:

const number = 4;

const squareRoot = Math.sqrt(4);

console.log(squareRoot); // 2