CodePeek
Practice / ValuesBack to CodePeek

JavaScript Nullish coalescing: Keep the zero

Puzzle 5 of 15 · Nullish coalescing

Compare logical OR (||) and nullish coalescing (??) when a score is zero. Predict which value each defaulting expression selects. Choose an output below, then check the explanation. No signup needed. Browse puzzles by topic →

Values / Nullish coalescingJavaScript
const score = 0;
console.log(score || 10);
console.log(score ?? 10);

Predict the console output. Each line is a separate log.

What’s the output?

Choose the output

Starter puzzles 15