Adding extra object in existing object

I have array from api like students= [ { name:‘steve’, email:‘steve@gmail.com’ } ]

how can I make it students= [ { name:‘steve’, email:‘steve@gmail.com’, score:’ ’ } ]

after fetching result from api ?

Normally people throw their code snippets here, so someone can point out on mistakes and collectively it will result in some form of a learning process. Did you try to do it yourself?

Yeah sorry for that, my code is here

So, you have an array of objects, so called collection. Normally, if you want to update every item in collection you would .map() it:

const updatedCollection = collection.map((item) => {
  // modify item
  return item; // modified
});
1 Like