I've been struggling to convert a nested array like the one below:
var array = [
[['firstName', 'Henry'], ['codeName', 'Etta'], ['email', '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5a323f3428231a32... },
[['firstName', 'Bruce'], ['codeName', 'DK'], ['email', '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6d240c002f2d000c03430e0...}
];
into an object format similar to this:
var newArray = [
{firstName: 'Henry', codeName: 'Etta', email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="422a272c303b022a23...},
{firstName: 'Bruce', codeName: 'DK', email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b0f9d1ddf2f0ddd1de9ed3d...}
];
I attempted a solution using the function below, but it didn't yield the desired outcome.
function arrIntoObject(array) {
var obj = {};
array.map(function(a) {
a.map(function(e) {
obj[e[0]] = e[1];
});
});
return obj;
}
This seems like a common issue, but despite my efforts, I haven't found a similar question. Any assistance or pointers would be greatly appreciated. Thank you!