text: Squares of numbers with repeated single digits | Set 1 ( 3 , 6 and 9 ) | Function to find the square of 333. . .333 , 666. . .666 and 999. . .999 ; if the number is 333. . .333 ; if the number is 666. . .666 ; if the number is 999. . .999 ; variable for hold result ; find the no of digit ; add size - 1 time a in result ; add one time b in result ; add size - 1 time c in result ; add one time d in result ; return result ; Drivers code ; find square of 33. .33 ; find square of 66. .66 ; find square of 66. .66
code: function find_Square_369 ( num ) { let a , b , c , d ; if ( num [ 0 ] == ' ' ) { a = ' ' ; b = ' ' ; c = ' ' ; d = ' ' ; } else if ( num [ 0 ] == ' ' ) { a = ' ' ; b = ' ' ; c = ' ' ; d = ' ' ; } else { a = ' ' ; b = ' ' ; c = ' ' ; d = ' ' ; } let result = " " ; let size = num . length ; for ( let i = 1 ; i < size ; i ++ ) result += a ; result += b ; for ( let i = 1 ; i < size ; i ++ ) result += c ; result += d ; return result ; } let num_3 , num_6 , num_9 ; num_3 = " " ; num_6 = " " ; num_9 = " " ; let result = " " ; result = find_Square_369 ( num_3 ) ; document . write ( " " + num_3 + " " + result + " " ) ; result = find_Square_369 ( num_6 ) ; document . write ( " " + num_9 + " " + result + " " ) ; result = find_Square_369 ( num_9 ) ; document . write ( " " + num_9 + " " + result + " " ) ;