Explore Library
Code QuizIntermediate

Truthiness Narrowing Drops Zero

A truthiness check accidentally excludes a valid zero value.

Codetypescript
function printCount(count: number | undefined) {
  if (count) {
    console.log(`Count: ${count}`);
  } else {
    console.log("No count provided");
  }
}

printCount(0); // prints "No count provided"

What is the bug in this code?