I need to populate a JSON file:
{"element":{"id":10,"quantity":1}}
And I need to add another "element". My first step is putting that JSON in an Object type using cart = JSON.parse. Now I need to add the new element:
var element = {};
element.push({ id: id, quantity: quantity });
cart.push(element);
But I got:
Object has no method push
on element.push, I think because I'm not referencing the "element" anywhere. How can I do that?
let result = rowData.slice(); result.forEach(e =>e.push({action: 'test')};