Adsense

Remove duplicate characters from string

function nonRepeaters(s) {
  var h={};
  return s.split("").
    map(function(c){h[c] |= 0; h[c]++; console.log(c); return c}).
    filter(function(c){console.log(h[c]);return h[c] == 1}).
    join("");
 }

nonRepeaters("abcab")

output :

 a
 b
 c
 a
 b
 2
 2
 1
 2
 2

"c"

newest questions on wordpress