Chapter 8 : Tuples

Tuples gather multiple values in a specific order which can be retrieved with their indexes.

To define a tuple, use [ ] operator :

type name = [string, string];

And to define a value of this type :

let my_name: name = ["Jack", "Oneill"];


You can access each component of a tuple by their position:

const my_name_first_name: string = my_name[0];const my_name_last_name: string = my_name[1];


You can modify a component of tuple by assigning values as if it were a variable :

my_name[0] = "Carter"

Your mission

1- Create a tuple type coordinates representing a 3D location.

2- Define earth_coordinates at coordinates 2,7,1.

3- Let’s say you made a mistake in the definition. Change the last parameter of earth_coordinates to 5.