Closed ghost closed 8 years ago
function affordItems(mob_amt, acces_amt, bank_amt, tax_rate){
var i = 0, amtFinal = 0; amtFinal = (mob_amt + acces_amt) + (mob_amt * tax_rate); var totTax = 0; for(bank_amt; bank_amt > mob_amt; bank_amt -= mob_amt){ totTax += amtFinal - mob_amt; i++; } if (i > 0) { console.log('You can afford: '+ i + ' item(-s) and accessories.\nMoney left: $' + bank_amt.toFixed(2) + '.\nTaxes paid: $' + totTax.toFixed(2)); } else { console.log('No sufficient bank amount!'); };
}
// get 'bank_amt' by 'prompt()' var bank_amt = prompt(), // let's enter, f.e.: 1500 tax_rate = 0.13;
affordItems(199.99, 2.99, bank_amt, tax_rate);
You can afford: 7 item(-s) and accessories. Money left: $100.07. Taxes paid: $202.92
What's the issue here?
Closing for now since there's no response from OP. I don't understand this issue either.
function affordItems(mob_amt, acces_amt, bank_amt, tax_rate){
}
// get 'bank_amt' by 'prompt()' var bank_amt = prompt(), // let's enter, f.e.: 1500 tax_rate = 0.13;
affordItems(199.99, 2.99, bank_amt, tax_rate);