AI

Functions are reusable blocks of code. Let's create helper functions to calculate totals.

Your Task:

  • Create a function calculateSubtotal(items) that sums up item prices
  • Create a function calculateDiscount(subtotal, percent) that returns discount amount
  • Use them to calculate subtotal, discount, and finalTotal
TypeScript Solution
Loading...

Submit your code to see test results