1 · First steps · 8 MIN
Calculate a total
Expressions calculate values.
Multiplication happens before addition. Parentheses let you make the intended order explicit. Access a property on an input object using a dot, such as input.price. Here the input contains whole-number quantities and prices; real payment systems need an explicit rounding policy.
A shopping receipt multiplies each item price by its quantity before calculating a total.
Read the example
const price = 4; const quantity = 3; console.log(price * quantity);
Check the expected output
12
Your challenge
Return input.price multiplied by input.quantity. Input is an object with both numbers.
Common trap
"4" + 3 makes "43". Keep quantities numeric.
Next lesson: Choose a path →