Question 6
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
const count = 0;
console.log(count || 10, count ?? 10);
- A 0 0
- B 10 0 Correct
- C 10 10
- D 0 10
Correct Answer: Option B
0 is falsy, so || returns 10. 0 is not null or undefined, so ?? keeps it.
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!