0
const obj = {name:'James',age:25};
const address = [{add1:'USA'},{add2:'UK'}]

Expecting : obj={name:'James',age:25,tag:[{add1:'USA'},{add2:'UK'}]};

Tried does not work for me

Object.entries(address).forEach(([key,value]) => { obj[key] = value })
Sunil Dubey
  • 113
  • 9

1 Answers1

0

let obj = {name:'James',age:25};
let address = [{add1:'USA'},{add2:'UK'}];
obj['tag'] = [...address];
const resultObj = obj;

console.log(resultObj);
Arm144
  • 591
  • 1
  • 7
  • 19