In my possession are an array of players along with their names and ratings.
$scope.players = [
{"name": "Qasim", "rating": "10"},
{"name": "Mahsam", "rating": 10},
{"name": "Aj", "rating": 3},
{"name": "Osman", "rating": 7},
{"name": "Usama", "rating": 7},
{"name": "Bilal", "rating": 3}
]
The task at hand is to categorize players into two teams based on their ratings.
var playerLength = $scope.players.length,
grouped = _.groupBy($scope.players,function(item){return item.rating});
The objective is to form two balanced teams with equal ratings.