I have a javascript object that is DYNAMICALLY CREATED like this
[
{"user":"James","errors":["signature must be signed!"]},
{"user":"Jones","errors":["signature must be signed!"]}
]
I am trying to dynamically add a new error in errors array inside that object.
This is what i have tried:
validationErr.push({ "user" : "James", "errors" : ["start time musst be filled!"] });
But i get a new entry
[
{"user":"James","errors":["signature must be signed!"]},
{"user":"Jones","errors":["signature must be signed!"]},
{"user" : "James", "errors" : ["start time musst be filled!"]}
]
instead of this
[
{"user":"James","errors":["signature must be signed!", "start time musst be filled!"]},
{"user":"Jones","errors":["signature must be signed!"]},
]
How can I add to existing array inside my object?