Square root in javascript

in #javascript5 years ago

#js-beginners-series #lesson-003

Square root in javascript

Writing a square root of a number in this form √ in arithmetic operations won't work
In this example, I employed the square root of 4 in a simple addition operation

console.log(√4);
// output : SyntaxError: Invalid or unexpected token

As a result, in that format, a square root could not be executed and it could not be used as a number. However, its correct format is Math.sqrt()
Here's an example :

console.log(Math.sqrt(4));
// output : 2

Thank you for reading !!!