WeCodeAcademy

Typing Functions

Annotate parameters and the return type. Parameters are the most important place to write types.

Exampletypescript
Open in editor »

Calling a function with the wrong argument types or count is an error.

Exampletypescript
Open in editor »
Quick check

What does `: number` after the parameter list describe?

Your turn: write the code

Write a function area(w: number, h: number): number that returns width times height, then print area(3, 4).

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.