Question: Create a function declaration called calculateTax() that takes a dollar amount as a parameter and calculates the tax. If the amount is less than or
Create a function declaration called calculateTax() that takes a dollar amount as a parameter and calculates the tax.
- If the amount is less than or equal to $5.00, apply 20% tax. If the amount is greater than or equal to $5.01 and less than or equal to $100, apply 15% tax. If the amount is $100.01 or more, apply 5% tax. Add the tax amount to the original amount and return the new total.
- Ensure that you round the final amount to 2 decimal places and return it as a Number type, not string.
- This function should be 'pure' in that it should only return a simple value.
- If the user tries to pass in a non-numeric value return the string "invalid", as a string type.
JAVASCRIPT.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
