- 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();
Result
Goalscompleted
- Change the message
We’ll get miles for the flight to Irkutsk
to a more universal:We’ll get miles for the flight
. - Add parameter
distance
to the function. - In the function call, specify argument
4125
. - Inside the function body, delete variable
distance
. - At the end of the program, add another
calculateMiles
call with argument11000
.
Comments