Adding extra object in existing object

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

how can I make it students= [ { name:‘steve’, email:‘’, 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 = => {
  // modify item
  return item; // modified
1 Like