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

JavaScript

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

Thanks! We’ll fix everything at once!

Result

  1. Change the message We’ll get miles for the flight to Irkutsk to a more universal: We’ll get miles for the flight.
  2. Add parameter distance to the function.
  3. In the function call, specify argument 4125.
  4. Inside the function body, delete variable distance.
  5. At the end of the program, add another calculateMiles call with argument 11000.