Algorithm to generate possible combinations of players from all players of team

Let's say I have 3 postions [goalkeeper, midfilder, striker] and 6 players

[{"name":A, "position":goalkeeper, "salary":300, "rating" : 9},
{"name": B, "position":goalkeeper, "salary":200, "rating" : 8 },
{"name": C, "position":midfilder, "salary":400 , "rating" : 9},
{"name": D, "position":midfilder, "salary":300 , "rating" : 7},
{"name": E, "position":striker, "salary":400, "rating" : 9 },
{"name": F, "position":striker, "salary":200 ,"rating" : 7}]

Now I need to build all possible combinations of teams with all 3 positions from 6 player with maximum ratings and within my total budget salary of 1100.

Output should be like this

[{ "team" : [A,C,E],
    "total_salary" : 1100,
    "total_rating" : 27
  },
 { "team" : [B,C,E],
    "total_salary" : 1000,
    "total_rating" : 26
  },
  { "team" : [A,D,E],
    "total_salary" : 1000,
    "total_rating" : 25
  }.. all possible combinations. Players will be choosed based on position. there can't be 2 players with same position.]

I found bit of solution here : combinations of players for a team in C But it seems in C but seems not feasible and I need it in JAVASCRIPT.