Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started