Two functions decide whether there is a count to show. Both type-check under --strict. What does it log?
function withTruthiness(count: number | undefined): string {
if (count) return `${count} new`;
return "no data";
}
function withUndefinedCheck(count: number | undefined): string {
if (count !== undefined) return `${count} new`;
return "no data";
}
console.log(withTruthiness(3));
console.log(withTruthiness(0));
console.log(withUndefinedCheck(0));
console.log(withUndefinedCheck(undefined));
console.log(withTruthiness(NaN));