Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var origBank = prompt("What's your account balance?"); // passed in amount
- var spendingThreshold = prompt("What's your spending threshold?"); // passed in amount
- var bank = origBank;
- const PRICE = 20;
- const PRICE_ACCESSORIES = 10;
- const TAX_RATE = 0.0825;
- var number = 0;
- var numAccess = 0;
- var subTotal = 0;
- var total = 0;
- function taxPaid(subTotal) {
- return(subTotal * TAX_RATE);
- }
- function subTotalCalc(number, numAccess) {
- subTotal = (number * PRICE) + (numAccess * PRICE_ACCESSORIES);
- return(subTotal)
- }
- while (origBank > total) {
- number = number + 1;
- numAccess = numAccess + 1;
- total = subTotalCalc(number, numAccess) + taxPaid(subTotal);
- bank = origBank - total;
- console.log (number);
- console.log(numAccess);
- console.log("I've spent $" + total.toFixed(2) + " on phones and phone accessories so far today. I've got $" + bank.toFixed(2) + " left in the bank.");
- }
Add Comment
Please, Sign In to add comment