I've a data like this.
const arr = [
{name:'john'},
{name:'jeff'},
{name:'bob'},
{name:'peter'},
]
arr.forEach((v,i,a)=>{
console.log(v)
})
And I want to transfer to
arr = [{id:1,name:john},{id:2,name:jeff},{id:3,name:bob},{id:4,name:peter}]
I want to add id to every object in array.
How to solves this, Thank you.
forEach?