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”