I have 2 arrays with the following data
Array 1 has 8 elements, may vary, never more than 30 elements
I copy pasted these values from my browser console, thought that would be most readable.
Array1
0: {date_usage: "2021-01-28 00:05:28", receipts: 3}
1: {date_usage: "2021-02-01 00:05:28", receipts: 4}
2: {date_usage: "2021-02-02 00:05:28", receipts: 8}
3: {date_usage: "2021-02-05 15:05:16", receipts: 4}
4: {date_usage: "2021-02-09 15:05:17", receipts: 13}
5: {date_usage: "2021-02-10 11:12:10", receipts: 1}
6: {date_usage: "2021-02-18 00:05:29", receipts: 5}
7: {date_usage: "2021-02-19 15:05:18", receipts: 3}
Array 2 has 30 elements.
It is an array with the dates of last 30 days.
All 'receipts' are 0 and all times may vary.
Array2
0: {date_usage: "2021-01-21 00:00:00", receipts: 0}
1: {date_usage: "2021-01-22 14:00:00", receipts: 0}
2: {date_usage: "2021-01-23 09:00:00", receipts: 0}
3: {date_usage: "2021-01-24 10:00:00", receipts: 0}
..............etc
29: {date_usage: "2021-02-21 00:00:00", receipts: 0}
I would like to add the missing dates to Array 1 with JavaScript or create a new array containing this data.
The times don't need to match, only the dates.
Each date will only appear once in both arrays.
I know it's a simple question, and many variants of it exist on this forum.
But every time I try a solution I get stuck, so I hope someone can help and point me in the right direction.
If something is unclear, let me know and I'll elaborate further.