0
0
Javascriptprogramming~15 mins

Arithmetic operators in Javascript - Mini Project: Build & Apply

Choose your learning style9 modes available
Arithmetic Operators Practice
📖 Scenario: You are helping a small shop calculate prices and discounts for their products. You will use arithmetic operators to do simple math calculations.
🎯 Goal: Build a small program that calculates the total price of items, applies a discount, and shows the final amount to pay.
📋 What You'll Learn
Create variables with exact values for product prices
Create a variable for discount percentage
Calculate total price and discounted price using arithmetic operators
Print the final price after discount
💡 Why This Matters
🌍 Real World
Calculating prices and discounts is common in shops and online stores to show customers how much they pay.
💼 Career
Understanding arithmetic operators is essential for any programming job that involves calculations, such as web development, data analysis, or game programming.
Progress0 / 4 steps
1
Create product price variables
Create three variables called price1, price2, and price3 with values 10, 20, and 30 respectively.
Javascript
Need a hint?

Use let to create variables and assign the exact numbers.

2
Create discount percentage variable
Create a variable called discountPercent and set it to 10 to represent a 10% discount.
Javascript
Need a hint?

Remember to use let and assign the number 10.

3
Calculate total and discounted price
Create a variable called totalPrice that adds price1, price2, and price3. Then create a variable called discountedPrice that subtracts the discount amount from totalPrice. Use arithmetic operators to calculate the discount amount as totalPrice * discountPercent / 100.
Javascript
Need a hint?

Use + to add prices and -, *, and / to calculate the discount.

4
Print the final discounted price
Write a console.log statement to print the text "Final price after discount: " followed by the value of discountedPrice.
Javascript
Need a hint?

Use console.log and string concatenation with +.