Advertisement
Todorov_Stanimir

02. Flight Schedule Objects and Classes - More Exercises

Dec 10th, 2019
1,478
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function flightSchedule(input) {
  2.     let flights = {};
  3.     input[0].forEach(line => {
  4.         let [numberFly, destination] = line.split(' ')
  5.         flights[numberFly] = {
  6.             Destination: destination,
  7.             Status: 'Ready to fly'
  8.         }
  9.     });
  10.     input[1].forEach(line => {
  11.         let [numberFly, status] = line.split(' ');
  12.         if (flights.hasOwnProperty(numberFly)) {
  13.             flights[numberFly].Status = status;
  14.         }
  15.     });
  16.     for (let fly in flights) {
  17.         if (flights[fly].Status === String(input[2])) {
  18.             console.log(flights[fly]);
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement