Interactive online courses HTML Academy
2026-03-09 12:26 Diff
  • 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');

Thanks! We’ll fix everything at once!

Result

  1. In the calculateMiles function after checking the flight class, add another check. If the distance is greater than 3500 km, the percentage increases by another 0.15.
  2. Increase the distance in both function calls to 10000 to make sure that the number of miles has increased.