Find the characters in a string which are not duplicated

We can also now clean things up using filter method:

function removeDuplicateCharacters(string) {
  return string
    .split('')
    .filter(function(item, pos, self) {
      return self.indexOf(item) == pos;
    })
    .join('');
}
console.log(removeDuplicateCharacters('baraban'));

Working example:

Leave a Comment