Interactive online courses HTML Academy
2026-03-09 14:10 Diff
  • 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; };

Thanks! We’ll fix everything at once!

Result

  1. After the calculateMiles function, declare function calculateFlights with two parameters distance and isBusinessClass.
  2. Inside the new function, declare variable miles, which is equal to the result of function calculateMiles(distance, isBusinessClass).
  3. Then log in the console the value of variable 'Miles per flight: ' + miles.
  4. Below, after declaring all functions, call function calculateFlights(3118, true);.