Advertisement
bebo231312312321

Untitled

Feb 28th, 2023
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function flightSchedule(input) {
  2.     let schedule = [];
  3.     input[0].forEach(el => {
  4.         let [flyNumber, info] = el.split(' ')
  5.        
  6.         let scheduleList={}
  7.             scheduleList.flightNumber = flyNumber
  8.             scheduleList.Destination = info,
  9.             scheduleList.status = "Ready to fly"
  10.         schedule.push(scheduleList)
  11.         //console.log(scheduleList.Status)
  12.     });
  13.  
  14.  
  15.    for (let el of input[1]){
  16.         let flightNumber = el.split(' ');
  17.         let findFlight = schedule.filter((obj) => obj.flightNumber === flightNumber[0])[0];
  18.    
  19.         if (findFlight) {
  20.           findFlight.status = 'Cancelled';
  21.         }
  22.     }
  23.         let action = input[2][0];
  24.         let flights = schedule.filter((obj) => obj.status === action)
  25.      
  26.         if(action === "Cancelled"){
  27.             flights.forEach((el)=>
  28.             console.log(`{ Destination: '${el.Destination}', Status: '${el.status}' }`)
  29.             );
  30.         }
  31.          
  32.        
  33.        if(action === "Ready to fly"){
  34.         flights.forEach((el)=>
  35.         console.log(`{ Destination: '${el.Destination}', Status: '${el.status}' }`)
  36.         );
  37.        }
  38.    
  39.        
  40.      
  41.         //schedule.push(scheduleList)
  42.       //  console.log(scheduleList.Status)
  43.    
  44.     };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement