0 of 6 problems solved0%
4 of 6

Tuple as Coordinates

Tuples represent fixed-length arrays with known element types. Aliasing a tuple clarifies intent (e.g., a coordinate). Return a new tuple instead of reusing the argument.

  • Use a tuple alias for coordinates.
  • Keep calculations simple and avoid mutating inputs.
  • Return the translated coordinate.

Your Task

  1. Define type Coord = [number, number].
  2. Implement translate(c: Coord, dx: number, dy: number): Coord returning a new coordinate [c[0] + dx, c[1] + dy].