JavaScript Code

Find Square Root of a Number Program

Problem Statement

given a number, write a JavaScript program with a function that takes the number as argument, finds the square root of this number, and returns the result


to find the square root of a number in JavaScript, we can use Math.sqrt() method.


function findSquareRoot(num) {
    return Math.sqrt(num);

var a = 5;
const result = findSquareRoot(a);

Math.sqrt() function is used in the above program. JavaScript Math library contains trivial functions related to mathematics