I'm getting my array list through jQuery's each function.
var spnTxt = '';
var arr = $('#id').find('span').each(function(utval) {
spnTxt = $(this).text();
});
This is giving me
["pet", "dog", "london", "class"]
["pet", "cat", "newyork", "weight"]
["tech", "phone", "spain", "hello2"]
["tech", "phone", "spain", "hello"]
["tech", "phone", "spain", "hello"]
In my above example, i should get
["pet", "dog", "london", "class"]
["pet", "cat", "newyork", "weight"]
["tech", "phone", "spain", "hello2"]
["tech", "phone", "spain", "hello"]
Which is of unique. And my below code doesnt work. I'm not sure if its correct.
var dup = {};
var arr = $('#id').find('span').each(function(utval) {
spnTxt = $(this).text();
if (dup[spnTxt])
$(this).remove();
else
dup[spnTxt] = true;
});
Basically i want to remove duplicate array, if my strings in arrays are exactly similar to each other. How to achieve this