I am working on the React app, and there I have an array shopsAsArray
. This array looks like this:
[
{
"shopName":"Billa",
"ID":"01",
"ratings":[
{
"stars":5,
"comment":"Good assortiment."
},
{
"stars":5,
"comment":"Very Tasty Food!"
}
]
},
{
"shopName":"Albert",
"ID":"02",
"ratings":[
{
"stars":5,
"comment":"Nice"
},
{
"stars":4,
"comment":"Not bad"
}
]
}
]
I need to add a new comment to one of these shops. This shop is the same as variable chosenShop
.
So my task is to add a new comment to the shop that has the same ID
as chosenShop
.
I know that the next function is wrong, but I don’t know how to fix it:
shopsAsArray.get(chosenShop.ID).push(newComment);