I need to find the ID associated with a specific date in an array. The code I have tried using includes()
is not working as expected.
const results = [];
angular.forEach(getEventdate, function(value)
{
results.push({id:value.id,event_date:value.event_date}); });
if(results.some(result => result.event_date === current_date))
{
console.log('date exists!');
}
Here is a sample array:
0: {id: 4, event_date: "2019-01-11"}
1: {id: 6, event_date: "2019-01-11"}
2: {id: 7, event_date: "2019-01-11"}
3: {id: 8, event_date: "2017-06-13"}
4: {id: 9, event_date: "2017-06-14"}
5: {id: 10, event_date: "2017-06-21"}
6: {id: 11, event_date: "2017-06-22"}
7: {id: 12, event_date: "2017-06-23"}
8: {id: 13, event_date: "2017-06-26"}
9: {id: 14, event_date: "2017-06-27"}
If the current date exists in the array, I want to retrieve the associated id
.