WeCodeAcademy

Arrays and Tuples

Write an array type as type[]. Every item must match.

Exampletypescript
Open in editor »

A tuple is an array with a fixed length and a type for each position.

Exampletypescript
Open in editor »
Exampletypescript
Open in editor »
Quick check

How do you write the type "array of strings"?

Your turn: write the code

Declare nums as a number[] containing 1, 2 and 3, then print their sum (use reduce).

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.