I have array, for example:
var arr = ['ab', 'cd', 'cd', 'ef', 'cd'];
Now I want to remove duplicates which is side by side, in this example it's at index 1 & 2 (cd).
result must be:
var arr = ['ab', 'cd', 'ef', 'cd'];
I tried this code but it's not working:
var uniqueNames = [];
$.each(arr, function(i, el){
if($.inArray(el, uniqueNames) === -1) uniqueNames.push(el);
});
but this filters unique and I don't want this.
['ab', 'cd', 'cd', 'cd', 'ef', 'cd']..?