Perfect Square String | JavaScript program to find if string is a perfect square or not . ; Calculating the length of the string ; Calculating the ASCII value of the string ; Find floating point value of square root of x . ; If square root is an integer ; Driver code
function isPerfectSquareString ( str ) { var sum = 0 ; var len = str . length ; for ( var i = 0 ; i < len ; i ++ ) sum += str . charCodeAt ( i ) ; var squareRoot = Math . sqrt ( sum ) ; return squareRoot - Math . floor ( squareRoot ) == 0 ; } var str = " " ; if ( isPerfectSquareString ( str ) ) document . write ( " " ) ; else document . write ( " " ) ;