text: Encrypt a string by repeating i | Function to return the encrypted String ; Number of times the current character will be repeated ; Repeat the current character in the encrypted String ; Driver code
code: function encryptString ( str , n ) { let i = 0 , cnt = 0 ; let encryptedStr = " " ; while ( i < n ) { cnt = i + 1 ; while ( cnt -- > 0 ) encryptedStr += str [ i ] ; i ++ ; } return encryptedStr ; } let str = " " ; let n = str . length ; document . write ( encryptString ( str , n ) ) ;