Find the squire root of a number input by the user using javascript.
Javascript program to find to squire root of a number
658
16-Feb-2023
Updated on 26-Nov-2023
Aryan Kumar
26-Nov-2023You can find the square root of a number in JavaScript using the Math.sqrt() function. Here's a simple example:
In this example, the findSquareRoot function takes a number as an argument, checks if it's non-negative, and then uses Math.sqrt() to calculate the square root. If the number is negative, it returns NaN (Not a Number).
You can change the value of numToFindSquareRoot to find the square root of different numbers. Note that the result will be a floating-point number, even if the input is an integer.