Exercise 1: Calculate the Tax

Test your function implementation and rest parameter skills.

Problem statement

An amountAfterTaxes() function returns the total amount after all the taxes are applied. Let’s implement that function so the output for each call in the next code shows up as expected.

Function description

Implement the function in such a way that it calculates every tax for the specific amount and returns the total amount after adding all of the provided taxes to it.

Sample input and output

The function returns the total tax amount after calculating all the tax amounts.

Function call Output
amountAfterTaxes(amount) 25.12
amountAfterTaxes(amount, fedTax) 27.63
amountAfterTaxes(amount, fedTax, stateTax) 28.13
amountAfterTaxes(amount, fedTax, stateTax, localTax) 28.26

Exercise

The solution to this exercise is available in the code widget below. However, it’ll be good practice to solve this problem on your own first. Good luck!

Get hands-on with 1200+ tech skills courses.