Why cant the function see either the Quantity or Discount variables?
The Quantity variable is declared outside the function and the Discount variable is declared in it

var Quantity = document.getElementById("Quantity").value;
function CalculateTotal() {
}

shouldn’t the function be able to see the variable?

Something that might help is that there’s a consistent pattern to the discount, that you can represent as a formula.

I realized that 30 gives 0.2, and 80 gives 0.7
Multiplying the discount by 10 results in 30=>2 and 80=>7
From there, you can add one to the discount and multiply by 10, to get the quantity value.

Reversing all of that lets us get from the quantity to the discount.

discount = (quantity / 10 - 1) / 10

Using parseInt so that we end up with single decimal point values, results in the following discount function:

function discount(quantity) {
var amount = parseInt(quantity / 10 - 1, 10) / 10;
if (amount > 0.9) {
amount = 0.9;
}
return amount;
}