My goal is to iterate through multiple objects, comparing the date_created key value of each object to a specific string. These objects are retrieved from an array that I can map over to display the results. Once I loop through each object, I want to push those with a date_created key value equal to my string into a new array.
I have included examples of how I currently fetch the objects, but I am seeking guidance on how to efficiently loop through and compare the key value to the specified string.
Initial Data Output
(14) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
0: {4: "X", 5: "X", 6: "X", 7: "X", 8: "X", 9: "X", id: "X", form_id: "X", post_id: "X",
date_created: "2020-08-10 01:28:59", date_updated: "X", …}
1: {4: "X", 5: "X", 6: "X", 7: "X", 8: "X", 9: "X", id: "X", form_id: "X", post_id: "X",
date_created: "2019-11-08 02:56:03", date_updated: "X", …}
2: {4: "X", 5: "X", 6: "X", 7: "X", 8: "X", 9: "X", id: "X", form_id: "X", post_id: "X",
date_created: "2019-10-09 15:05:16", date_updated: "X", …}
)
Code for rendering list of objects (Mapping over initial data to extract objects from array)
If there is a more effective way to initially retrieve the objects, please advise.
resData.map(result => {
console.log(result);
});
Result of Mapping Array of Objects:
{4: "X", 5: "X", 6: "X", 7: "X", 8: "X", 9: "X", id: "X", form_id: "X", post_id: "X",
date_created: "2020-08-10 01:28:59", date_updated: "X", …}
{4: "X", 5: "X", 6: "X", 7: "X", 8: "X", 9: "X", id: "X", form_id: "X", post_id: "X",
date_created: "2019-11-08 02:56:03", date_updated: "X", …}
{4: "X", 5: "X", 6: "X", 7: "X", 8: "X", 9: "X", id: "X", form_id: "X", post_id: "X",
date_created: "2019-10-09 15:05:16", date_updated: "X", …}