> For the complete documentation index, see [llms.txt](https://eleven-fifty-academy.gitbook.io/javascript-101-fundamentals/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://eleven-fifty-academy.gitbook.io/javascript-101-fundamentals/1-javascript-fundamentals/1-js-fundamentals/4-functions/closures-challenge.md).

# Closures Challenge

```javascript
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);
```
