I have to convert an array of arrays into an object and I don't know how to do it. I have tried this way but the result is not what I expected.I don't know how to return
input = [[ 'Thundercats', '80s' ], [ 'The Powerpuff Girls', '90s' ], [ 'Sealab 2021', '00s' ]];
function objectify(array){
array.forEach(el=>{
el.reduce(function(result, item,index,array){
result[index] = item;
return result;
}, {})
})
return ??;
}
console.log(objectify(input))
Una solución con una sola línea:
const obj = Object.fromEntries(array);