I have any array that looks like this:
[
{ "tempValue": "Sunday CLOSE to CLOSE" },
{ "tempValue": "Sunday CLOSE to 08:30" },
{ "tempValue": "Sunday CLOSE to 08:30" },
{ "tempValue": "Tuesday CLOSE to 08:30" },
{ "tempValue": "Thursday CLOSE to 08:30" }
]
I need to remove all the dupliactes from this array. In the above example, the duplicates are Sunday
...
So I tried something like this:
function unique(list) {
var result = [];
$.each(list, function(i, e) {
if ($.inArray(e, result) == -1) result.push(e);
});
return result;
}
unique(hours);
The variable hours
is my array.
But my code above doesn't work!
Could someone please advice on this issue?
EDIT:
The desired output is this:
[
{ "tempValue": "Tuesday CLOSE to 08:30" },
{ "tempValue": "Thursday CLOSE to 08:30" }
]