Closures Challenge
var calculateTotalWithTip = function (totalWithoutTip, tipPercentage) {
let totalWithTip;
function calculateTip(totalWithoutTip, tipPercentage) {
let tipAmount = totalWithoutTip * tipPercentage;
return tipAmount;
}
totalWithTip = calculateTip(totalWithoutTip, tipPercentage) + totalWithoutTip;
return totalWithTip;
}
var tipAmount = calculateTotalWithTip(100, .20);
console.log(tipAmount);
Last updated