Interactive online courses HTML Academy
2026-03-09 12:27 Diff
  • script.js

JavaScript

var calculateMiles = function (distance, isBusinessClass) { if (isBusinessClass) { return distance * 0.22; } else { return distance * 0.18; } };

Thanks! We’ll fix everything at once!

Result

  1. After defining the function, create variable milesEconom, which is equal to the result of the expression calculateMiles(3000, false);.
  2. Create another variable milesBusiness, which is equal to the result of calculateMiles(3000, true);.
  3. Log the following message in the console'With economy class from MuffAir, you’ll get ' + milesEconom + ' miles'.
  4. And then log this message in the console 'With business class of MuffAir, you’ll get ' + milesBusiness + ' miles'.