<file_sep>##Affordable Phone Purchase

* Write a program to calculate the total price of your phone purchase. You will keep purchasing phones (hint: loop!) until you run out of money in your bank account. You'll also buy accessories for each phone as long as your purchase amount is below your mental spending threshold.
* After you've calculated your purchase amount, add in the tax, then print out the calculated purchase amount, properly formatted.
* Finally, check the amount against your bank account balance to see if you can afford it or not.
* You should set up some constants for the "tax rate," "phone price," "accessory price," and "spending threshold," as well as a variable for your "bank account balance.""
* You should define functions for calculating the tax and for formatting the price with a "$" and rounding to two decimal places.

**This is a practice taken from <NAME>'s "You Don't Know JS"<file_sep>var SPENDING_LIMIT = 500;
var SALES_TAX = 0.09;
var PHONE = 120;
var ACCESSORY = 20;

var available_funds = 1000.01;
var cost = 0;

function totalCost(cost) {
    return "$" + cost.toFixed(2);
}
// purchase of phones while funds are still avail
while (cost < available_funds) {
    cost = cost + PHONE;
    // if there are funds to buy accessories
    if (cost < SPENDING_LIMIT) {
        cost = cost + ACCESSORY;
    }
}

function calculateTax(cost) {
    return cost * SALES_TAX;
}

// need to incorporate sales tax
cost = cost + calculateTax(cost);
console.log(
    "Your purchase: " + totalCost(cost)
);

// checks if the phone is affordable; enough money in avaialable funds
if (cost > available_funds) {
    console.log(
        "You do not have enough funds."
    );
}
