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.

  1. 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.
  2. Ensure that you round the final amount to 2 decimal places and return it as a Number type, not string.
  3. This function should be 'pure' in that it should only return a simple value.
  4. 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!