I've got an array with some objects :
var myArray = [{
'id': 'first',
'value': 'firstValue'
}, {
'id': 'second',
'value': 'secondValue'
}, {
'id': 'third',
'value': 'thirdValue'},
etc.];
I'm trying to add values with a loop so that I have something like this :
var myArray = [{
'id': 'first',
'value': 'firstValue',
'inc1' : 1
}, {
'id': 'second',
'value': 'secondValue'
'inc2' : 2
}, {
'id': 'third',
'value': 'thirdValue'
'inc3' : 3
}];
I know that with mapping
myArray.forEach(function(o, i) {
o.inc = i + 1;
});
I can get the results incremented, but how do I get the names inc1, inc2, inc3...?