KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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?
Tags (comma-separated)
Save Edits
Cancel