- script.js
JavaScript
var calculateMiles = function (distance, isBusinessClass) {
var percent = 0.18;
if (isBusinessClass) {
percent += 0.04;
}
return distance * percent;
};
var milesEconom = calculateMiles(3000, false);
var milesBusiness = calculateMiles(3000, true);
console.log('With economy class from MuffAir, you’ll get ' + milesEconom + ' miles');
console.log('With business class of MuffAir, you will save ' + milesBusiness + ' miles');
Result
Goalscompleted
- In the
calculateMilesfunction after checking the flight class, add another check. If the distance is greater than3500km, the percentage increases by another0.15. - Increase the distance in both function calls to
10000to make sure that the number of miles has increased.
Comments