Checking if more than one character have frequency greater than 1.
let count = 0 ; for ( let j = 0 ; j < 26 ; j ++ ) { if ( freq [ j ] % 2 != 0 ) { count ++ ; } } if ( count <= 1 ) { document . write ( " " ) ; } else { document . write ( " " ) ; } }