- script.js
JavaScript
var calculateMiles = function (distance, isBusinessClass) {
var percent = 0.18;
if (isBusinessClass) {
percent += 0.04;
}
if (distance > 3500) {
percent += 0.15;
}
return distance * percent;
};
var calculateFlights = function (distance, isBusinessClass, milesTarget) {
var miles = calculateMiles(distance, isBusinessClass);
console.log('Miles for the flight: ' + miles);
var flights = Math.ceil(milesTarget / miles);
console.log('Number of flights: ' + flights);
};
calculateFlights(3118, true, 15000);
Result
Goalscompleted
- Inside the
calculateFlights
function, delete log of values in the console. - Return the number of flights using
return
from thecalculateFlights
function. - Replace the
calculateFlights(3118, true, 15000)
function call with logging the following message in the console'Required number of flights in business class to Valencia: ' + calculateFlights(3118, true, 15000)
. - Add one more message below
'Required number of economy flights to Lisbon: ' + calculateFlights(3617, false, 15000)
.
Comments