In the frontend, I am utilizing a datepicker that sends a date through an AJAX Request. The date is in the format 'YYYY-MM-DD'. I need to compare this date with dates in an array retrieved from a MongoDB collection. These dates include a Timezone and are formatted as follows: "2020-06-03T00:00:00.000Z"
Slot Json Object
{
date: [
2020-06-03T00:00:00.000Z,
2020-06-05T00:00:00.000Z,
2020-06-07T00:00:00.000Z
],
__v: 0
}
I have to iterate over each date in the array and compare it with the date from the frontend.
Assuming the user input date is
let userInput = '2020-06-03';
I need to ensure that comparing '2020-06-03' with '2020-06-03T00:00:00.000Z' returns true. How can I achieve this comparison while looping through all elements in the array?