Essentially I have some data like this:
[
{
"Forename": "Scott",
"Surname": "Jones",
"Age": 18,
},
{
"Forename": "Tina",
"Surname": "Turner",
"Age": 20,
},
{
"Forename": "Joe",
"Surname": "Bloggs",
"Age": 20,
}
]
I want to know how to add in a key value pair using javascript like so:
[
{
"id": 1,
"Forename": "Scott",
"Surname": "Jones",
"Age": 18,
},
{
"id": 2,
"Forename": "Tina",
"Surname": "Turner",
"Age": 20,
},
{
"id": 3,
"Forename": "Joe",
"Surname": "Bloggs",
"Age": 20,
}
]
I was looking at stuff like mapping through the and adding it to each object but that seemed to only let me add a key value pair to the end of each one.
Any help / guidance appreciated!