I am experiencing an issue with json.stringify. I have a button on-click event that triggers a function to add another object to the array variable.
var example = [{name: "K", age: 12},{name: "L", age: 12}];
var jsonE = JSON.stringify(example);
Despite adding more objects to the 'example' variable, the value of jsonE remains unchanged.
I am looking for a way to continuously update the json data as new objects are added to the array. Is there a specific loop or method I should be using?
SOLUTION:
Update the JSON.stringify when the on-click event is triggered.