I have JSON array like this
var array= [{id:1,name:'foo'},{id:2,name:'bar'}]
I would like to add a new key (eg:isApproved
) to each object in the existing array
expected output:
var array= [{id:1,name:'foo',isApproved:true},{id:2,name:'bar',isApproved:true}]
I used the map function to achieve this
array.map(function(e,index){
e.isApproved[index]= true
}
But this not worked for me