Skip to content

Instantly share code, notes, and snippets.

@brunosabot
Created March 30, 2022 17:45
const soccerTeam = [
new Goalkeeper(),
new Defender(), //...
];
const [goalkeeper, defender, ...fieldPlayers] = soccerTeam;
// Goal keeper stay in his field
goalkeeper.stayInField();
// One defender should also stay
defender.stayInField();
// All the other field players should attack
fieldPlayers.map((player) => player.attack());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment