Advertisement
ggeorgiev88

fligths

Mar 10th, 2023
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function flightSchedule(arr) {
  2.  
  3.     let fligthData = arr.shift();
  4.     let status = arr.shift();
  5.     let printStatus = arr.shift();
  6.  
  7.     let fligthList = {};
  8.     let statusChange = {}
  9.  
  10.  
  11.     for (let x = 0; x < fligthData.length; x++) {
  12.         let all = fligthData[x].split(" ");
  13.         let flightNumber = all.shift();
  14.         let destontion = all.join(" ")
  15.         if (!fligthList.hasOwnProperty(flightNumber)) {
  16.             fligthList[flightNumber] = [];
  17.             fligthList[flightNumber].push(destontion)
  18.         }
  19.     }
  20.     for (let x = 0; x < status.length; x++) {
  21.         let [statusNum, statusInfo] = status[x].split(" ");
  22.         if (fligthList.hasOwnProperty(statusNum)) {
  23.             fligthList[statusNum].push(statusInfo);
  24.         }
  25.     }
  26.     let filter = Object.entries(fligthList).filter(([fligthNum, arr]) => arr.length > 1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement