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"
Login to get access to the exclusive discord channel.