I'm using underscore in an Angular controller and attempting to turn a string into an object with several properties.
vm.availableGames = _.each(availableGames, function(game) {
game.name = game;
if (_.contains(user.allowed_games.games, game)) {
game.allowed = true;
} else {
game.allowed = false;
}
});
availableGames
is an array of strings of available games
allowed_games
is also an array of strings of allowed games
My aim is to create an array of objects (vm.availableGames
) which contains all available games. Each of these objects will have a name property (the original string) and an allowed property (a boolean).
The above code results in a Cannot assign to read only property...
error. How would I go about accomplishing what I'm aiming for without running into this error?