Interactive online courses HTML Academy
2026-03-09 14:11 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, milesTarget) { var miles = calculateMiles(distance, isBusinessClass); console.log('Miles for the flight: ' + miles); var flights = Math.ceil(milesTarget / miles); console.log('Number of flights: ' + flights); }; calculateFlights(3118, true, 15000);

Thanks! We’ll fix everything at once!

Result

  1. Inside the calculateFlights function, delete log of values in the console.
  2. Return the number of flights using return from the calculateFlights function.
  3. Replace the calculateFlights(3118, true, 15000) function call with logging the following message in the console 'Required number of flights in business class to Valencia: ' + calculateFlights(3118, true, 15000).
  4. Add one more message below 'Required number of economy flights to Lisbon: ' + calculateFlights(3617, false, 15000).