I have two arrays - one contains dates and the other contains objects. My goal is to include the dates as a key value pair in each object, like this: {"Date": "10-12-18"}
.
dates
:
["10-12-18", "10-13-18", 10-14-18"]
data
:
[
{"name":"One", "age": "4"},
{"name":"Two", "age": "5"},
{"name":"Three", "age": "9"}
]
I envision my final data structure to look something like this...
[
{"name":"One", "age": "4", "Date": "10-12-18"},
....
I am struggling with TypeScript so far as I am more accustomed to regular JavaScript. Here's what I've attempted:
for (let idx of data){
data[idx].date = dates[idx]
}
Any tips on how to solve this would be greatly appreciated!