Check if given number is perfect square | JavaScript program to find if x is a perfect square . ; Find floating point value of square root of x . ; if product of square root is equal , then return T / F ; Driver code
function isPerfectSquare ( x ) { if ( x >= 0 ) { let sr = Math . sqrt ( x ) ; return ( ( sr * sr ) == x ) ; } return false ; } let x = 2500 ; if ( isPerfectSquare ( x ) ) document . write ( " " ) ; else document . write ( " " ) ;