Interactive online courses HTML Academy
2026-03-09 10:57 Diff
  • script.js

JavaScript

var percent = 0.25; var distance = 4125; if (distance > 10500) { percent = 0.35; } var miles = distance * percent; console.log('We’ll get ' + miles + ' miles for the flight to Irkutsk'); // Delete the code below var percent = 0.25; var distance = 11000; if (distance > 10500) { percent = 0.35; } var miles = distance * percent; console.log('We’ll get ' + miles + ' miles for the flight to Kamchatka');

Thanks! We’ll fix everything at once!

Result

  1. Delete the entire code for calculating the miles of the second flight (variables, condition and log in the console).
  2. Add function declaration for counting miles at the end of the program: var calculateMiles = function () { };.
  3. Transfer the entire remaining code calculating miles into the body of the calculateMiles function.