I have this code where I added two Reviews (with the ID and NAME):
var data = {
SKU: 'CS4',
Name: 'Dell Laptop Inspiron 41',
Quantity: 1,
ItemPrice: 121,
"Reviews" : [
{
"ID": 2551,
"Name": 'john',
},
{
"ID": 255551,
"Name": 'j5ohn',
}
};
How can I add them dynamically (i will get the reviews data from other sites using ajax) ?
I tried these code but I don't know why its not working and I am totally lost.
var data = [{
SKU: 'CS4',
Name: 'Dell Laptop Inspiron 41',
Quantity: 1,
ItemPrice: 121,
}];
var total_reviews = 5;
for (i=1; i<=total_reviews; i++) {
Object.assign(data.Reviews, { "ID": data.from.other.sites.ID, "Name": data.from.other.sites.NAME });
}
Can you please give me advise which part I am missing ? or can you give me hints or codes for me to start?