I'm struggling to find a way to print the array of values in a specific order after looping through an object.
**Here is the challenge:**
Given a set of game outcome records, the task is to identify all the players and create an array of their names in the order they appear.
Example Input:
[
{ winner: 'Alishah', loser: 'Bob', loser_points: 3 },
{ winner: 'Maria', loser: 'Xu Jin', loser_points: 1 },
{ winner: 'Elise', loser: 'Bob', loser_points: 2 },
{ winner: 'Elise', loser: 'Maria', loser_points: 4 },
{ winner: 'Alishah', loser: 'Maria', loser_points: 2 },
{ winner: 'Maria', loser: 'Xu Jin', loser_points: 3 },
{ winner: 'Xu Jin', loser: 'Elise', loser_points: 2 }
]
Expected Result:
['Alishah', 'Bob', 'Maria', 'Xu Jin', 'Elise']
**Here's the code snippet I've been working on:**
let data = [
{ winner: 'Alishah', loser: 'Bob', loser_points: 3 },
{ winner: 'Maria', loser: 'Xu Jin', loser_points: 1 },
{ winner: 'Elise', loser: 'Bob', loser_points: 2 },
{ winner: 'Elise', loser: 'Maria', loser_points: 4 },
{ winner: 'Alishah', loser: 'Maria', loser_points: 2 },
{ winner: 'Maria', loser: 'Xu Jin', loser_points: 3 },
{ winner: 'Xu Jin', loser: 'Elise', loser_points: 2 }
];
console.log(main(data));