Fix the Discount Calculation Bug

Repair a JavaScript function so it returns the correct discounted product price.

Beginner5–10 minutesJavaScriptJavaScriptDebugging

Mission scenario

An online store has a discount calculator.

A product costs ₹800 and the discount is 10%.

Your objective

Fix calculateTotal so the correct discounted price is returned.

  • Return ₹720 for a price of ₹800 with a 10% discount.
  • Return the expected total for the other supplied test cases.
Example input
₹800, 10% off
Current output
₹800
Expected total
₹720

Your solution is evaluated against fixed mission tests in a browser worker. Learner code is not sent to the server. This client-side restriction is not a general-purpose security sandbox.

Want to explore the related course? Full-Stack Development

Challenge workspace

Edit the function, then run the deterministic checks.

Attempts: 0

Trusted preview

Product price
₹800.00
Discount
10%
Current total
₹800.00
Expected total
₹720.00

Loading code editor…

Use one calculateTotal(price, discountPercent) function with a return expression. Supported: numbers, these two inputs, parentheses, and +, -, *, /, or %.

Test results

Run the tests to check your function.

Hints