Convert array of objects to single object
let arrayToObject = (arr) => {
return arr.reduce(
(obj, item) => Object.assign(obj, { ...item }),
{}
);
}
let arr = [
{
"01": ["google.com", "github.com"]
},
{
"02": ["stackoverflow.com"]
},
{
"03": ["nodejs.com"]
}
];
console.log(arrayToObject(arr));
// {
// "01": ["google.com", "github.com"],
// "02": ["stackoverflow.com"],
// "03": ["nodejs.com"]
// }