Interactive online courses HTML Academy
2026-03-09 12:25 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; }; var calculateFlights = function (distance, isBusinessClass) { var miles = calculateMiles(distance, isBusinessClass); console.log('Miles for the flight: ' + miles); }; calculateFlights(3118, true);

Thanks! We’ll fix everything at once!

Result

  1. Create third parameter milesTarget in calculateFlights function and transfer third argument 15000 in the call of calculateFlights function.
  2. Inside calculateFlights function, after logging miles in the console, declare variable flights, which equals milesTarget / miles.
  3. Log the number of flights in the console 'Number of flights:' + flights.
  4. Round the number of flights up Math.ceil(milesTarget / miles).