Write a function that accepts an array of tickets, where ticket has format [source: string,
destination: string] and returns comma separated countries in order of visiting.
function getRoute(tickets){
return 'USA,BRA,UAE,JPN,PHL'; // implement logic here
}
const result = getRoute([['JPN', 'PHL'], ['BRA', 'UAE'], ['USA', 'BRA'], ['UAE',
'JPN']]);
console.log(result);
Example:
Tickets: [["JPN", "PHL"], ["BRA", "UAE"], ["USA", "BRA"], ["UAE", "JPN"]]
Result: "USA, BRA, UAE, JPN, PHL