Change string to a new character set | JavaScript program to change the sentence with virtual dictionary ; function for converting the string ; find the index of each element of the string in the modified set of alphabets replace the element with the one having the same index in the actual set of alphabets ; Driver Code
var alphabets = " " . split ( " " ) ; function conversion ( charSet , str1 ) { var s2 = " " ; str1 . forEach ( ( i ) => { s2 = s2 + alphabets [ charSet . indexOf ( i ) ] ; } ) ; return s2 ; } var charSet = " " ; var str1 = " " ; document . write ( conversion ( charSet , str1 . split ( " " ) ) ) ;