$ ./guess_the_languageProblem Solving — predict the output
Problem Solving — predict the output · hard · #126

What is logged?

let x = 0;
const y = x++ + ++x;
console.log(x, y);
  1. 2 2
  2. 2 3
  3. 1 1
  4. 2 1
x++ contributes 0 then x becomes 1; ++x makes it 2 and contributes 2.
Play Problem Solving ▸