Intern — Middle
Player selection based on team availability
livecode
Task condition
There is a list of players, each described by an object with the following properties:
- name: the player's name (string)
- term: the team number the player is part of (can be 1, 2, 3, 5, or null if the player is not associated with any team)
It is required to implement a function
filterplayersthat takes an array of such objects and returns an object containing two arrays: - withTeam: players whose
termfield is not null (i.e., they are part of a team); - withoutTeam: players whose
termfield is null (i.e., they do not belong to any team).