- 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);
Result
Goalscompleted
- Create third parameter milesTargetincalculateFlightsfunction and transfer third argument15000in the call ofcalculateFlightsfunction.
- Inside calculateFlightsfunction, after logging miles in the console, declare variableflights, which equalsmilesTarget / miles.
- Log the number of flights in the console 'Number of flights:' + flights.
- Round the number of flights up Math.ceil(milesTarget / miles).
Comments