I'm trying to map 2d array:
var fkOptionList2d = [[3, 'Orange'],[5, 'Banana'],[6, 'Coconut']]
to an associative array:
var fkOptionList1d = [{id: 1, label: 'Orange'},{id: 2, label: 'Banana'},{id: 3, label: 'Coconut'}]
but I'm new to underscore.js and don't quite get it yet. Should it be something like:
fkTableArr1d = _.object(_.map(fkTableArr2d, function(item, id) {
return [{"id: " + id,"label: " + item}]
}));
?
Unexpected identifiernearreturnreturn [{ id: id, label: item }]; you don't need to construct the object as a string (it's not JSON)