I currently have two arrays containing dates. I want to check if there's at least one match of values when comparing the two arrays. To clarify, these are Date objects and not strings. My code below always seems to return false:
var between = [Sun Aug 27 2017 00:00:00 GMT+0100 (BST), Mon Aug 28 2017 00:00:00 GMT+0100 (BST), Tue Aug 29 2017 00:00:00 GMT+0100 (BST), Wed Aug 30 2017 00:00:00 GMT+0100 (BST)];
var myDate = [Mon Aug 28 2017 00:00:00 GMT+0100 (BST), Thu Aug 24 2017 00:00:00 GMT+0100 (BST)];
var bExists = false;
$.each(myDate, function(index, value){
if($.inArray(value,between)!=-1){
console.log(value);
bExists = true;
}
if(bExists){
return false; //break
}
});
console.log(bExists);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>