Looking for a solution:
const myArray = []
myArray.push( { "bob" : { "banana" : "yellow" } })
console.log(myArray)
Output:
{
"bob": {
"banana": "yellow"
}
}
Attempting a modification:
const myArray = []
const name = "bob"
const fruit = "banana"
const fruitcolor = "yellow"
myArray.push( { name : { fruit : fruitcolor } })
console.log(myArray)
Unfortunately, the result is not as expected. Any suggestions on how to correct this issue would be greatly appreciated.
Thank you!