Untitled

Run Settings
LanguageJavaScript
Language Version
Run Command
airportSystem.addAirport("JFK", "New York", "USA"); airportSystem.addAirport("LAX", "Los Angeles", "USA"); airportSystem.addAirport("LHR", "London", "UK"); airportSystem.displayAirportInfo("JFK"); airportSystem.searchAirportsByCity("New York"); airportSystem.updateAirportInfo("JFK", "New York City", "USA"); airportSystem.displayAirportInfo("JFK"); airportSystem.removeAirport("LAX"); airportSystem.searchAirportsByCity("Los Angeles"); class Airport { constructor(code, cit... by Effendi, Loudy Effendi, Loudy 6:41 PM class Airport { constructor(code, city, country) { this.code = code; this.city = city; this.country = country; } } class AirportSystem { constructor() { this.airports = {}; } addAirport(code, city, country) { if (!this.airports[code]) { this.airports[code] = new Airport(code, city, country); console.log(`Airport ${code} added successfully.`); } else { console.log("Airport with this code already exists."); } } displayAirportInfo(code) { const airport = this.airports[code]; if (airport) { console.log(`Airport Code: ${airport.code}`); console.log(`City: ${airport.city}`); console.log(`Country: ${airport.country}`); } else { console.log("Airport not found."); } } searchAirportsByCity(city) { const foundAirports = Object.values(this.airports).filter(airport => airport.city === city); if (foundAirports.length > 0) { foundAirports.forEach(airport => { console.log(`Airport Code: ${airport.code}, Country: ${airport.country}`); }); } else { console.log("No airports found in this city."); } } updateAirportInfo(code, newCity, newCountry) { if (this.airports[code]) { this.airports[code].city = newCity; this.airports[code].country = newCountry; console.log("Airport information updated successfully."); } else { console.log("Airport not found."); } } removeAirport(code) { if (this.airports[code]) { delete this.airports[code]; console.log("Airport removed successfully."); } else { console.log("Airport not found."); } } } // Example usage: const airportSystem = new AirportSystem(); airportSystem.addAirport("JFK", "New York", "USA"); airportSystem.addAirport("LAX", "Los Angeles", "USA"); airportSystem.addAirport("LHR", "London", "UK"); airportSystem.displayAirportInfo("JFK"); airportSystem.searchAirportsByCity("New York"); airportSystem.updateAirportInfo("JFK", "New York City", "USA"); airportSystem.displayAirportInfo("JFK"); airportSystem.removeAirport("LAX"); airportSystem.searchAirportsByCity("Los Angeles");
Editor Settings
Theme
Key bindings
Full width
Lines