vladovip

Flight Schedule- Object and Classes - JS

Apr 26th, 2021
633
349 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. function flightSchedule(input) {
  3.    
  4.     let flights = {};
  5.     input[0].forEach(line => {
  6.         let [numberFly, destination] = line.split(' ')
  7.         flights[numberFly] = {
  8.             Destination: destination,
  9.             Status: 'Ready to fly'
  10.         }
  11.     });
  12.     input[1].forEach(line => {
  13.         let [numberFly, status] = line.split(' ');
  14.         if (flights.hasOwnProperty(numberFly)) {
  15.             flights[numberFly].Status = status;
  16.         }
  17.     });
  18.     for (let fly in flights) {
  19.         if (flights[fly].Status === String(input[2])) {
  20.             console.log(flights[fly]);
  21.         }
  22.     }
  23. }
  24.  
  25. flightSchedule (
  26.    
  27.     [
  28.         ['WN269 Delaware',
  29.    'FL2269 Oregon',
  30.     'WN498 Las Vegas',
  31.     'WN3145 Ohio',
  32.     'WN612 Alabama',
  33.     'WN4010 New York',
  34.     'WN1173 California',
  35.     'DL2120 Texas',
  36.     'KL5744 Illinois',
  37.     'WN678 Pennsylvania'],
  38.     ['DL2120 Cancelled',
  39.     'WN612 Cancelled',
  40.     'WN1173 Cancelled',
  41.     'SK330 Cancelled'],
  42.     ['Ready to fly']
  43. ]
  44.  
  45. );
  46.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×