CHALLENGE 3: any vs unknown ============================ SOLUTION: function doubleIfNumber(value: unknown): number { if (typeof value === "number") { return value * 2; } return 0; } EXPLANATION: Step 1: Accept unknown - "value: unknown" means we don't know what type it is - This is safer than 'any' because it forces us to check Step 2: Check the type - "typeof value === "number"" narrows the type - Inside the if block, TypeScript KNOWS value is a number Step 3: Use the value safely - "return value * 2" is safe because we checked first - TypeScript allows this multiplication Step 4: Default return - "return 0" if the value isn't a number - We always return a number (the function's return type) WHY NOT USE 'any'? If you wrote it like this: function doubleIfNumber(value: any): number { return value * 2; // ✅ Technically works, but wrong! } This would: - NOT enforce type checking - Return NaN if value is a string - Hide potential bugs - Defeat the entire purpose of TypeScript TYPE NARROWING: The "typeof value === 'number'" check is called type narrowing. After that check, TypeScript knows value must be a number. This pattern is fundamental to writing safe TypeScript. TESTING: doubleIfNumber(5) // Returns 10 ✅ doubleIfNumber(3.5) // Returns 7 ✅ doubleIfNumber("5") // Returns 0 (not a number) doubleIfNumber(null) // Returns 0 (not a number) doubleIfNumber(true) // Returns 0 (not a number)