Modify the string such that every character gets replaced with the next character in the keyboard | JavaScript implementation of the approach ; Function to return the modified string ; Map to store the next character on the keyboard for every possible lowercase character ; Update the string ; Driver code
var CHARS = " " ; var MAX = 26 ; function getString ( string , n ) { var string = string . split ( " " ) ; uMap = [ ] ; for ( let i = 0 ; i < MAX ; i ++ ) { uMap [ CHARS [ i ] ] = CHARS [ ( i + 1 ) % MAX ] ; } for ( let i = 0 ; i < n ; i ++ ) { string [ i ] = uMap [ string [ i ] ] ; } return string . join ( " " ) ; } var string = " " ; var n = string . length ; document . write ( getString ( string , n ) ) ;