Replace every vowels with lexicographically next vowel in a String | Function to replace every vowel with next vowel lexicographically ; Storing the vowels in the map with custom numbers showing their index ; Iterate over the string ; If the current character is a vowel Find the index in Hash and Replace it with next vowel from Hash ; Driver function
function print_next_vovel_string ( st ) { var m = { } ; m [ " " ] = 0 ; m [ " " ] = 1 ; m [ " " ] = 2 ; m [ " " ] = 3 ; m [ " " ] = 4 ; var arr = [ " " , " " , " " , " " , " " ] ; var N = st . length ; for ( let i = 0 ; i < N ; i ++ ) { var c = st [ i ] ; if ( c === " " c === " " c === " " c === " " c === " " ) { index = m [ st [ i ] ] + 1 ; newindex = index % 5 ; st = st . replace ( st [ i ] , arr [ newindex ] ) ; } } return st ; } var st = " " ; document . write ( print_next_vovel_string ( st ) ) ;