Loading workspace environment...
Learn the difference between expressions (which evaluate to a value) and statements (which perform an action).
// Notice how parentheses control expression evaluation order
const resultWithoutParens = 10 + 5 * 2; // 5 * 2 happens first (10 + 10 = 20)
const resultWithParens = (10 + 5) * 2; // 10 + 5 happens first (15 * 2 = 30)
console.log("10 + 5 * 2 =", resultWithoutParens);
console.log("(10 + 5) * 2 =", resultWithParens);10 + 5 * 2 = 20
(10 + 5) * 2 = 3010 + 5 * 2Multiplication has higher precedence than addition.const average = 80 + 90 + 100 / 3; // Evaluates to 80 + 90 + 33.33 = 203.33!const average = (80 + 90 + 100) / 3; // Evaluates to 270 / 3 = 90Architectural Explanation: Without parentheses, division occurs before addition due to operator precedence.
Write an expression for a cart with 3 items at $15 each, plus 8% tax (0.08), minus a $5 coupon. Log the total.