I thought I had everything correct and I still can't seem to figure out why the function isn't working out the way it is supposed to. I have this issue where the code is having a reference error but I'm not sure how to define the function. I also put it through the W3 validator but that's not telling me anything.

```
<!DOCTYPE HTML>
<html lang="en-us">
  <head>
    <meta charset="utf-8">
    <title>discount amount</title>
  </head>
  <body>
    <script>
     /* Input: purchase amount
      * Processing: determine through if statements if they get a discount
      * Output: final price after tax
      */
      // Computes and returns a discounted purchase amount.
      function getDiscountedAmount(purchase) {
        var purchase =
          parseInt(document.getElementById('purchase').value);
        var dayOfWeek = new Date().getDay();
        var output = document.querySelector("#output");

        let rate;
        if (purchase < 50) {
          rate = 0.06;
        } else if (purchase < 100 && [2, 3].includes(dayOfWeek)) {
          rate = 0.06;
        } else if (purchase < 500 && [2, 3].includes(dayOfWeek)) {
          rate = 0.06;
        }

        let discount = purchase * rate;
        return purchase - discount;
        output.innerHTML = "$" + String(getDiscountedAmount(200));
      }
    </script>
    Please enter your final price: <input type="text" id="purchase" size="5">
    <br>
    <button type="button" onclick="getDiscountedAmount(purchase)">discount?
    </button>
    <div id="output"></div>
  </body>
</html>

```