Skip to content

Instantly share code, notes, and snippets.

@guifromrio
Created March 13, 2016 09:19
Show Gist options
  • Save guifromrio/437314a2697fecdbbf15 to your computer and use it in GitHub Desktop.
Save guifromrio/437314a2697fecdbbf15 to your computer and use it in GitHub Desktop.
var array = [{name: "Foo", points: 1}, {name: "Bar", points: 3}];
var increasePoints = function (player) {
return {name: player.name, points: player.points + 1};
};
var newArray = [];
_.each(array, function (player) {
newArray.push(increasePoints(player));
});
// array is undisturbed! a little clunky, though...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment