Replace all consonants with nearest vowels in a string | Function to replace consonant with nearest vowels ; Driver code
function replacingConsonants ( s ) { var nVowel = " " ; for ( var i = 0 ; i < s . length ; i ++ ) s [ i ] = nVowel [ s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ; return s . join ( ' ' ) ; } var s = " " . split ( ' ' ) ; document . write ( replacingConsonants ( s ) ) ;