Interactive online courses HTML Academy
2026-03-09 14:11 Diff
  • script.js

JavaScript

var calculateMiles = function (distance, isBusinessClass) { if (isBusinessClass) { return distance * 0.22; } return distance * 0.18; }; 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’ll save ' + milesBusiness + ' miles');

Thanks! We’ll fix everything at once!

Result

  1. In the body of the function, it the very beginning, create variable percent equal to 0.18 on the 2nd line.
  2. Inside the condition, instead of calculating miles, increase variable percent by 0.04.
  3. Replace the expression that the function returns with distance * percent.