[Solved] How to add key value pair to the json?


You can do something like this:

var students = [ { city: 'California', company: 'ABC'}, { city: 'LA', company: 'PQR'}, { city: 'Mumbai', company: 'XYZ'}];
        
students.forEach((obj) => {
  obj['email']= '[email protected]';
  console.log(obj);
});

// Final Output
console.log(students);

0

solved How to add key value pair to the json?