← Quiz: JavaScript Basics: all 9 questions
Quiz: JavaScript Basics · Question 5 of 9
What does this print? (code)
What does this print?
const x = 0;
console.log(x || 10, x ?? 10);
- A.10 10
- B.10 0
- C.0 0
- D.0 10
Answer & explanation
Correct answer: 10 0
|| replaces any falsy value (0 → 10); ?? replaces only null/undefined (0 stays).
Can you get the rest right without peeking?
Take the timed Quiz: JavaScript Basics quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →