//This code will help people to reserve their plane tickets through the online platform of the airline.
/The following arrays are the databases that are used to make the reservation process less complicated/
let northAmericanCountries = [‘Mexico’,‘Canada’,‘US’];
let southAmericanCountries = [‘Brazil’, ‘Argentina’,‘Peru’,‘Costa Rica’,‘Chile’,‘Bolivia’,‘Colombia’,‘El Salvador’,‘Guatemala’,‘Honduras’,‘Nicaragua’,‘Panama’,‘Paraguay’,‘Dominican Republic’,‘Uruguay’];
let africanCountries = [‘Nigeria’,‘Ethiopia’,‘Egypt’,‘Democratic Republic of the Congo’,‘Tanzania’,‘South Africa’,‘Kenya’,‘Uganda’,‘Morocco’,‘Ghana’,‘Madagascar’,‘Cameroon’,‘Senegal’];
let europeanCountries = [‘Germany’,‘United Kingdom’,‘France’,‘Italy’,‘Spain’,‘Ukraine’,‘Poland’,‘Greece’,‘Netherlands’,‘Portugal’,‘Belgium’,‘Ireland’,‘Iceland’,‘Norway’,‘Denmark’];
let asianCountries = [‘China’,‘India’,‘Indonesia’,‘Pakistan’,‘Japan’,‘Philippines’, ‘Vietnam’,‘South Korea’,‘Saudi Arabia’,‘United Arab Emirates’,‘Israel’,‘Sigapore’,‘Qatar’];
//From where the customer is going to travel.
let placeOfOrigin = ‘Mexico’;
//The customer’s destination/
let destination = ‘Canada’;
//Days the customer will be traveling.
let travelingDays = ‘7’;
//How many people is going to travel.
let peopelToTravel = ‘2’;
//The following function will help the customer to look to the estimated price of their tickets in US dollars.
for(let i = 0; i < northAmericanCountries.length; i++){
if (placeOfOrigin == northAmericanCountries[i] && destination == northAmericanCountries[i] ){
return ‘North America’}{
for(let j = 0; j < southAmericanCountries.length; j++){
if(placeOfOrigin == southAmericanCountries[j] && destination == southAmericanCountries[j]){
return ‘South America’}{
for(let k = 0; k < africanCountries.length; k++){
if(placeOfOrigin == southAmericanCountries[k] && destination == southAmericanCountries[k]){
return ‘Africa’}{
for (let u = 0; u < europeanCountries.length; u++){
if(placeOfOrigin == europeanCountries[u] && destination == europeanCountries[u]){
return ‘Europe’}{
for (let g = 0; g < asianCountries.length; g++){
if(placeOfOrigin == asianCountries[g] && destination == asianCountries[g]){
return ‘Asia’}
}
}
}
}
}
}
}
}
};
function determineTotalPrice(placeOfOrigin,destination){
if(placeOfOrigin === ‘North America’ && destination === ‘North America’){
return ‘$50 dollars’;}
else if (placeOfOrigin === ‘North America’ && destination === ‘South America’){
return ‘$75 dollars’;}
else if (placeOfOrigin === ‘North America’ && destination === ‘Europe’){
return ‘$100 dollars’;}
else if (placeOfOrigin === ‘North America’ && destination === ‘Africa’){
return ‘$100 dollars’;}
else if (placeOfOrigin === ‘North America’ && destination === ‘Asia’){
return ‘$150 dollars’;}
};
console.log(determineTotalPrice(‘North America’, ‘North America’))
Do you have a specific question?
This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.