Skip to main content
Journey Uncommon Logo
JourneyUncommon
easyTypeScriptunion and literal typesSingle-choice MCQ

What is the type of `x` inside the `if`, and is `x.toFixed()` allowed there?

function describe(x: string | number) { if (typeof x === "string") { return x.length; } return x.toFixed(2); }