25 - Building a mini online store with a custom discount program (JS lessons)
๐ Task: Online Store with Discount Program
Create an application "Shop Calculator".
The user can select products and a client type.
After clicking the Calculate button, calculate the final price.
๐ Products:
- Phone โ $800
- Laptop โ $1200
- Watch โ $300
The user selects products using checkboxes.
๐ค Client type:
- New client โ 0% discount
- Regular client โ 10% discount
- VIP client โ 25% discount
The client type is selected using a select.
๐ Calculation logic:
- First, calculate the subtotal of selected products
- Then apply the discount based on the client type
- Calculate the discount amount
- Calculate the final total price
๐ Output:
- Subtotal โ total cost of selected products
- Discount (%) โ discount percentage
- Discount amount โ amount of discount
- Total โ final price to pay
๐งช Example:
- Phone + Laptop = $2000
- VIP client (25%) โ discount $500
- Total: $1500