Question 2
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
let i = 1;
const r = i++ + ++i;
console.log(i, r);
- A 3 3
- B 3 4 Correct
- C 2 4
- D 3 5
Correct Answer: Option B
Left to right: i++ gives 1 and makes i 2; ++i makes i 3 and gives 3. r = 1 + 3 = 4.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!