Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function tickets(input = [], criteria) {
- let result = []
- class Ticket {
- constructor(destination, price, status) {
- this.destination = destination;
- this.price = Number(price);
- this.status = status;
- }
- }
- for (const line of input) {
- let [city, price, status] = line.split('|');
- let data = new Ticket(city, price, status);
- result.push(data)
- }
- if (criteria === 'destination') {
- let sorted = Array.from(result);
- sorted.sort((a, b) => a[0].destination - b[0].destination)
- console.log(sorted);
- } else if (criteria === 'price') {
- } else {
- }
- }
- tickets(['Philadelphia|94.20|available',
- 'New York City|95.99|available',
- 'New York City|95.99|sold',
- 'Boston|126.20|departed'],
- 'destination')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement