I am trying to filter a table based on the user's input (search). This search string sends a teamId to the getFilteredPlayers function and I would like to return a list of players that are linked to that teamId. See an example of a player in the players array below;
See getFilteredPlayers function below, it is not returning anything currently. Please recommend some changes please
let getFilteredPlayers = (players, search) => {
if (search && search.length > 0) {
return players.filter((x) => {
return search.any((y) => x.playersTeams == y);
});
}
return players;
};