I have a string with repeated letters. I want letters that are repeated more than once to show only once. For instance I have a string aaabbbccc i want the result to be abc.
Here is the simplest function to do that
function remove(text) { var unique= ""; for(var i = 0; i < text.length; i++) { if(unique.indexOf(text.charAt(i)) < 0) { unique += text.charAt(i); } } return unique; }