text: Remove even frequency characters from the string | Function that removes the characters which have even frequencies in the string ; create a map to store the frequency of each character ; to store the new string ; remove the characters which have even frequencies ; if the character has even frequency then skip ; else concatenate the character to the new string ; display the modified string ; Driver Code ; remove the characters which have even frequencies
code: function solve ( s ) { let m = new Map ( ) ; for ( let i = 0 ; i < s . length ; i ++ ) { if ( m . has ( s [ i ] ) ) m . set ( s [ i ] , m . get ( s [ i ] ) + 1 ) ; else m . set ( s [ i ] , 1 ) ; } let new_string = " " ; for ( let i = 0 ; i < s . length ; i ++ ) { if ( m . get ( s [ i ] ) % 2 == 0 ) continue ; new_string = new_string + s [ i ] ; } document . write ( new_string ) ; } let s = " " ; solve ( s ) ;