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