How can I check if the two objects below have matching elements?
If they have matching elements ..I would like to store the matching elements in an empty variable called var storeHere = [].
var one = ["2021-02-25", "2021-02-24", "2021-02-23", "2021-02-22", "2021-02-21", "2021-03-02", "2021-02-11", "2021-02-10"];
var two = ["2021-02-25", "2021-02-25", "2021-02-23"];
var storeHere = [];
So far I managed to match the two objects and get either a true or a false if there is a match but i would also like to store the matching values in an emtpy variable.
var one = ["2021-02-25", "2021-02-24", "2021-02-23", "2021-02-22", "2021-02-21", "2021-03-02", "2021-02-11", "2021-02-10"];
var two = ["2021-02-25", "2021-02-25", "2021-02-23"];
function ex (alldates, selected) {
return selected.some(function (v) {
return alldates.indexOf(v) >= 0;
});
};
ex(one, two);