So i have an array:
pr = <?php echo json_encode($users); ?>;
Trying to map them:
pro = pr.map(it=> it.name); //usernames
pro1 = pr.map(it=> it.time); //date+time
Trying to remove duplicate names:
var filteredArr = pro.filter(function(item, index) {
if (pro.indexOf(item) == index)
return item;
});
It's working, but i want to add some more filter. And i have names like "Huan" and "Húan". There are duplicates, but with this method, i can't remove them.
My final goal is, to make an "if" statement, to filter dates and names.
So the logic:
if(today's date === array date) return names;
Outputs:
pr:
//with alert(JSON.stringify(pr));
[{"name":"john wick","time":"January 16, 10:27 AM"},{"name":"huan","time":"January 16, 10:28 AM"},{"name":"húan","time":"January 16, 10:28 AM"},{"name":"húan","time":"January 16, 14:28 AM"}]
pro:
//with alert(JSON.stringify(pro));
["john wick","huan","húan","húan"]
pro1:
//with alert(JSON.stringify(pro1));
["January 16, 10:27 AM","January 16, 10:28 AM","January 16, 10:28 AM","January 16, 14:28 AM"]
filteredArr:
//with alert(JSON.stringify(filteredArr));
["john wick","huan","húan"]
So my question is, how can i display names (only which are "linked" to today's date) ?