I want to create a final object structure, as shown below.
let finalArr = {
"friends":
[
{
"name": 'Jake',
"friendsList": [
"Friend1",
"Friend2",
"Friend3"
]
},
]
}
I start with this
let finalArr = {
"friends": [
]
}
In a loop, I obtain data and store it into an Array, like this
[
{
name: 'Jake',
friendsList: [
'Friend1',
'Friend2',
'Friend3',
]
},
How do I add the array I generate from the loop to the object, so that I can obtain the final structure that I want above? I tried Json.push but that doesn't seem to work, nor does a regular loop and plug, as that gives me out of bounds issues.
Json.push?finalArr.friends.pushwasn't working, but its because I was doing something dumb