Just looking for the cleanest way to turn the following array into the following object format. Thanks a lot
const item = [
{ address: '123 fake street },
{ loan: 'no' },
{ property: 'no' }
]
const obj = {
address: '123 fake street',
loan: 'no',
property: 'no'
}
>Solution :
You can use Object.assign() and spread syntax to convert the array of objects into a single object.
const item = [
{ address: '123 fake street' },
{ loan: 'no' },
{ property: 'no' }
]
const obj = Object.assign({}, ...item);
console.log(obj);