Skip to content

Instantly share code, notes, and snippets.

@LucasRoesler
Last active February 22, 2017 23:13
Show Gist options
  • Save LucasRoesler/3023c58dd64fd2b14f31f25f5afd543a to your computer and use it in GitHub Desktop.
Save LucasRoesler/3023c58dd64fd2b14f31f25f5afd543a to your computer and use it in GitHub Desktop.

Given the following collection of objects,

const collection = [
  { id: 1, name: “Han Solo”, title: “Scruffy Looking Nerf Herder”, allegiance: “rebellion” },
  { id: 2, name: “Darth Vader”, title: “Sith Lord”, allegiance: “empire” },
  { id: 3, name: “K-2SO”, title: “Sass-bot”, allegiance: “rebellion” },
  { id: 4, name: “Wilhuff Tarkin”, title: “Grand Moff”, allegiance: “empire” },
];

Using JavaScript, how would you:

  • Organize them alphabetically by “name”
  • Return a collection with only the IDs of each object in the collection
  • Mutate all objects in the collection to append “ - deceased” to the title
  • Remove the first object in the collection
  • Organize the collection into two groups, “empire” and “rebellion”
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment