In my JavaScript code, I have a result stored in an object named "availableDates". I am looking to extract the dates that have a value greater than 3 and place them into a new array.
"availableDates": {
"2020-01-24": 1,
"2020-01-23": 3,
"2020-01-22": 2,
"2020-01-21": 1,
"2020-01-25": 4,
"2021-01-07": 1
}
Here's the grouping function I'm using:
const formattedDate = x.reduce((acc,el) => {
const date = el.split(" ")[0];
acc[date] = (acc[date] || 0) + 1;
return acc;
}, {});
Now, I need to populate another array with all the dates that have a value greater than 3. For example:
newarray = [ "2020-01-23", "2020-01-25" ]