25.5k views
5 votes
write a function using fat arrow syntax, `salestax` that takes in an arbitrary number of arguments as prices, adds them up and returns a string containing the sales tax with a dollar sign in front. use a tax percentage of 9%.

User Urig
by
8.2k points

1 Answer

2 votes

Answer:

Step-by-step explanation:

const salesTax = (...allThePricesValAr) => {

sumOfPrices = 0

for(eachValPrc of allThePricesValAr){

sumOfPrices = sumOfPrices + eachValPrc

}

let taxOnPrcVal = sumOfPrices * 9 / 100;

let taxOnPrcVals = `$${taxOnPrcVal.toFixed(2)}`;

return taxOnPrcVals;

}

User Kiax
by
8.3k points