Is it possible to convert
[[35, "Bill"], [20, "Nancy"], [27, "Joan"]]
to
{"Bill": 35, "Nancy": 20, "Joan": 27}
using the .map() or .reduce() methods?
I can convert the array using:
const arr = [[35, "Bill"], [20, "Nancy"], [27, "Joan"]];
let obj = {};
for (let item of arr) {
obj[item[1]] = item[0];
}
console.log(obj);
But my attempts to do this using map or reduce are failing. Any ideas?