Challenge - 5 Problems
Arithmetic Operator Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of mixed arithmetic operations
What is the output of the following JavaScript code?
Javascript
const result = 10 + 5 * 2 - 8 / 4; console.log(result);
Attempts:
2 left
💡 Hint
Remember the order of operations: multiplication and division happen before addition and subtraction.
✗ Incorrect
Multiplication and division are done first: 5 * 2 = 10, 8 / 4 = 2. Then addition and subtraction: 10 + 10 - 2 = 18.
❓ Predict Output
intermediate2:00remaining
Result of increment and decrement operators
What will be logged to the console after running this code?
Javascript
let x = 5; console.log(x++ + ++x);
Attempts:
2 left
💡 Hint
Remember that x++ uses the value before increment, ++x increments before use.
✗ Incorrect
x++ returns 5 then x becomes 6; ++x increments x to 7 then returns 7; sum is 5 + 7 = 12.
❓ Predict Output
advanced2:00remaining
Output with modulus and exponentiation
What is the output of this code snippet?
Javascript
const a = 7 % 3; const b = 2 ** 3; console.log(a + b);
Attempts:
2 left
💡 Hint
Calculate modulus and exponentiation separately, then add.
✗ Incorrect
7 % 3 is 1 (remainder), 2 ** 3 is 8, sum is 1 + 8 = 9.
❓ Predict Output
advanced2:00remaining
Division and floating point precision
What will this code output?
Javascript
console.log(0.1 + 0.2 === 0.3);
Attempts:
2 left
💡 Hint
Think about how computers handle decimal numbers.
✗ Incorrect
Due to floating point precision, 0.1 + 0.2 is not exactly 0.3, so the comparison is false.
🧠 Conceptual
expert3:00remaining
Understanding operator precedence and associativity
Consider the expression: 4 + 3 * 2 ** 2 / 4 - 1. What is the final value?
Attempts:
2 left
💡 Hint
Remember the order: exponentiation, multiplication/division, addition/subtraction, and left-to-right associativity for same precedence.
✗ Incorrect
2 ** 2 = 4; then 3 * 4 = 12; 12 / 4 = 3; then 4 + 3 = 7; finally 7 - 1 = 6.