Answered step by step
Verified Expert Solution
Link Copied!

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.

  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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago