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

JavaScript

var calculateMiles = function (distance) { var percent = 0.25; if (distance > 10500) { percent = 0.35; } var miles = distance * percent; console.log('We’ll get ' + miles + ' miles for the flight'); }; calculateMiles(4125); calculateMiles(11000);

Thanks! We’ll fix everything at once!

Result

  1. Edit the value of the variable miles rounding the result of calculations Math.floor(distance * percent);.
  2. Inside the function, replace console log message with return miles;.
  3. Replace the first function call with console log message 'We’ll get ' + calculateMiles(4125) + ' for the flight to Irkutsk'.
  4. Replace the second function call with console log message 'We will get ' + calculateMiles(11000) + ' miles for the flight to Kamchatka'.