0
0
Javascriptprogramming~20 mins

Operator precedence in Javascript - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Operator Precedence Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this code with mixed operators?
Consider the following JavaScript code snippet. What will it print to the console?
Javascript
console.log(3 + 4 * 2 / (1 - 5) ** 2);
ASyntaxError
B1
C3.5
D3.75
Attempts:
2 left
💡 Hint
Remember that exponentiation (**) has higher precedence than multiplication and division, which have higher precedence than addition.
Predict Output
intermediate
2:00remaining
What is the output of this logical and arithmetic expression?
What will the following code output?
Javascript
console.log(true || false && false);
Atrue
Bfalse
CSyntaxError
Dundefined
Attempts:
2 left
💡 Hint
Remember that && has higher precedence than ||.
Predict Output
advanced
2:00remaining
What is the output of this tricky assignment expression?
What will this code print?
Javascript
let a = 1; let b = 2; let c = 3; console.log(a += b *= c);
A7
B6
C9
DTypeError
Attempts:
2 left
💡 Hint
Assignment operators are right-associative and have lower precedence than multiplication.
Predict Output
advanced
2:00remaining
What is the output of this expression with unary and binary operators?
What will the following code output?
Javascript
console.log(-3 ** 2);
A-6
B9
CSyntaxError
D-9
Attempts:
2 left
💡 Hint
Unary minus has lower precedence than exponentiation in JavaScript, so -3 ** 2 is parsed as -(3 ** 2) = -9.
Predict Output
expert
2:00remaining
What is the output of this complex expression mixing bitwise and logical operators?
What will this code print?
Javascript
console.log((5 & 3) || (0 && 2));
A0
B1
C2
DSyntaxError
Attempts:
2 left
💡 Hint
Bitwise AND (&) has higher precedence than logical AND (&&) and logical OR (||).