Sum of the digits of square of the given number which has only 1 's as its digits | Function to return the sum of the digits of num ^ 2 ; To store the number of 1 's ; Find the sum of the digits of num ^ 2 ; Driver code
function squareDigitSum ( s ) { let lengthN = s . length ; let result = parseInt ( lengthN / 9 ) * 81 + Math . pow ( ( lengthN % 9 ) , 2 ) ; return result ; } let s = " " ; document . write ( squareDigitSum ( s ) ) ;