Advertisement
vladovip

02. FlightSchedule_ObjAndClasses_ MoreEx

Feb 27th, 2022
1,263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.  
  3.     let firstArr = input.shift();
  4.     let secondArr = input.shift();
  5.     let thirdArr = input.shift();
  6.     let flights = {};
  7.  
  8.     for (const line of firstArr) {
  9.         let [number, Destination] = line.split(' ');
  10.         flights[number] = { Destination, Status: 'Ready to fly' }
  11.     }
  12.  
  13.     for (const line of secondArr) {
  14.         let [number, currentStatus] = line.split(' ');
  15.  
  16.         if (flights.hasOwnProperty(number)) {
  17.             flights[number].Status = currentStatus;
  18.         }
  19.     }
  20.  
  21.     for (const line in flights) {
  22.         if (flights[line].Status == thirdArr) {
  23.             console.log(flights[line])
  24.         }
  25.     }
  26.  
  27. }
  28.  
  29. solve ([['WN269 Delaware',
  30.     'FL2269 Oregon',
  31.     'WN498 Las Vegas',
  32.     'WN3145 Ohio',
  33.     'WN612 Alabama',
  34.     'WN4010 New York',
  35.     'WN1173 California',
  36.     'DL2120 Texas',
  37.     'KL5744 Illinois',
  38.     'WN678 Pennsylvania'],
  39. ['DL2120 Cancelled',
  40.     'WN612 Cancelled',
  41.     'WN1173 Cancelled',
  42.     'SK430 Cancelled'],
  43. ['Cancelled']
  44. ]
  45. )
  46.  
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement