- 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);
Result
Goalscompleted
- Edit the value of the variable
miles
rounding the result of calculationsMath.floor(distance * percent);
. - Inside the function, replace console log message with
return miles;
. - Replace the first function call with console log message
'We’ll get ' + calculateMiles(4125) + ' for the flight to Irkutsk'
. - Replace the second function call with console log message
'We will get ' + calculateMiles(11000) + ' miles for the flight to Kamchatka'
.
Comments