I have the following array;
["Test1", "Test2", "Test3"]
I want it to be like this;
[{ id: 0, name: "Test1" }, { id: 1, name: "Test2" }, { id: 2, name: "Test3" }]
Any Help?
I guess I should somehow use _.object() for this mission.
The map() function is your friend:
_.map(array, function(item, index) {
return { id: index, name: item };
});