I am attempting to filter a basic JSON file based on a specified date range, with both a start date and an end date.
Below is the function I have created for this task:
var startDate = new Date("2013-3-25");
var endDate = new Date("2017-3-25");
var aDate = new Date();
var filteredData = this.orders.filter(function(a){
aDate = new Date(a.fecha);
aDate >= startDate && aDate <= endDate;
});
console.log(filteredData)
You can view my code in action on this fiddle.
My expectation was to receive one object in my array, but unfortunately it appears empty when viewed in the console.