Skip to content

Instantly share code, notes, and snippets.

@Albert-IV
Created September 27, 2016 20:28
Show Gist options
  • Save Albert-IV/4e7a96a523601c7f1f9ac5555465d70c to your computer and use it in GitHub Desktop.
Save Albert-IV/4e7a96a523601c7f1f9ac5555465d70c to your computer and use it in GitHub Desktop.
fieldKeys = {
"1": "Name",
"2": "Email",
"3": "Some Field"
}
usefulInfo = entries.map(function(entryArr) {
return entryArr.reduce(function(obj, row, idx) {
var correctKey = fieldKeys[idx]
obj[correctKey] = row;
return obj;
}, {})
})
// usefulInfo == [{
// "Name": "Some Name",
// "Email" "example@email.com",
// "Some Field" : "WOOOO"
// },{
// "Name": "Some Name",
// "Email" "example@email.com",
// "Some Field" : "WOOOO"
// },{
// "Name": "Some Name",
// "Email" "example@email.com",
// "Some Field" : "WOOOO"
// },{
// "Name": "Some Name",
// "Email" "example@email.com",
// "Some Field" : "WOOOO"
// }]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment