Perfect Cube String | JavaScript program to find if string is a perfect cube or not . ; Finding ASCII values of each character and finding its sum ; Find the cube root of sum ; Check if sum is a perfect cube ; Driver code
function isPerfectCubeString ( str ) { var sum = 0 ; for ( var i = 0 ; i < str . length ; i ++ ) { sum += str . charCodeAt ( i ) ; } var cr = Math . round ( Math . cbrt ( sum ) ) ; return cr * cr * cr == sum ; } var str = " " ; if ( isPerfectCubeString ( str ) ) document . write ( " " ) ; else document . write ( " " ) ;