Fixed-Length Tuples

πŸ‘¨β€πŸ’Ό We need to work with geographic coordinates. Coordinates are always a pair of numbers: latitude and longitude.
🐨 Open and:
  1. Create coordinate values typed as [number, number] tuples
  2. Write a formatCoordinate function that takes a coordinate tuple
  3. Write a getDistance function that calculates distance between two coordinates
πŸ’° You can use inline tuple types like [number, number] directly, or create a type alias if you prefer:
type Coordinate = [number, number]
πŸ’° Tuple syntax:
const point: [number, number] = [10.5, 20.3]
πŸ’° Destructuring tuples:
const [lat, long] = coordinate

Please set the playground first

Loading "Fixed-Length Tuples"
Loading "Fixed-Length Tuples"