I have an array of arrays. I want to be able to loop over each array and for every array I want to add new keys or update existing values.
Here is what I have
var values = [];
values['123'] = [];
values['456'] = [];
values['123']['x1'] = 'value 1';
values['123']['x2'] = 'value 2';
I want to loop over the values array, and add new keys to the array for each array. (I.e values['123'] and values['456'])
Here is what I tried
$.each(values, function(index, value){
value['x1'] = 'new value 1';
value['x10'] = 'new value 10';
value['x20'] = 'new value 20';
console.log(value);
});
The console shows this error
TypeError: value is undefined
Here is a fiddle
How can I correcly loop over each array item and update the original array?