Courses
TypeScript for Beginners: Catch Wrong Data Before It Runs
Check Yourself: Functions That State Their Deal
Five scenario questions on parameter types, return types and defaults. If you miss more than one, go back to the two lessons before moving on.
Course content
Join this Course
Sign in to save your progress.
-
Before You Write Types
-
What TypeScript Adds on Top of JavaScript
-
Install TypeScript and Run Your First .ts File
-
-
-
Types You Cannot Skip
-
Annotating Variables Without Fighting the Compiler
-
Arrays, Objects and Nested Shapes
-
Optional, Readonly and Why any Is a Trap
-
-
-
Functions That State Their Deal
-
Parameter and Return Types
-
Optional and Default Parameters Without Surprises
-
-
-
Shapes You Can Reuse
-
Interfaces vs type Aliases: Pick One and Stick With It
-
Unions, Literals and Narrowing With typeof and in
-
-
-
Compile Without the Mystery
-
tsconfig.json: target, module and strict
-
Reading tsc Errors Without Panicking
-
-
- Final Check: TypeScript for Beginners
1.
You write function add(a, b) { return a + b; } in a strict project and get Parameter a implicitly has an any type. What is the right fix?
2.
A function declared as returning string has an if branch that returns "pass" and nothing after the if. What does the compiler report?
3.
A function does rate = rate || 0.12; and a customer has a rate of 0. The tax is calculated as if the rate were 0.12. What is the cleaner fix?
4.
You write function format(currency?: string, price: number). What does the compiler say and why?
5.
You call prices.map((p) => p.toUpperCase()) where prices is a number array. You never annotated p. Why does the compiler complain?
About
Five scenario questions on parameter types, return types and defaults. If you miss more than one, go back to the two lessons before moving on.
- Duration
- 5 min
- Last update
- 10/16/2026
Was this helpful?
0
0
Comments (0)
Sign in to commentNo comments yet.