Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function flightSchedule(input) {
- let schedule = [];
- input[0].forEach(el => {
- let [flyNumber, info] = el.split(' ')
- let scheduleList={}
- scheduleList.flightNumber = flyNumber
- scheduleList.Destination = info,
- scheduleList.status = "Ready to fly"
- schedule.push(scheduleList)
- //console.log(scheduleList.Status)
- });
- for (let el of input[1]){
- let flightNumber = el.split(' ');
- let findFlight = schedule.filter((obj) => obj.flightNumber === flightNumber[0])[0];
- if (findFlight) {
- findFlight.status = 'Cancelled';
- }
- }
- let action = input[2][0];
- let flights = schedule.filter((obj) => obj.status === action)
- if(action === "Cancelled"){
- flights.forEach((el)=>
- console.log(`{ Destination: '${el.Destination}', Status: '${el.status}' }`)
- );
- }
- if(action === "Ready to fly"){
- flights.forEach((el)=>
- console.log(`{ Destination: '${el.Destination}', Status: '${el.status}' }`)
- );
- }
- //schedule.push(scheduleList)
- // console.log(scheduleList.Status)
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement