From 52330a509fc1909760cedc3efd58ff18f8aa3e39 Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Tue, 19 May 2026 17:58:25 +0000 Subject: [PATCH] [Sync Iteration] typescript/space-age/1 --- solutions/typescript/space-age/1/space-age.ts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 solutions/typescript/space-age/1/space-age.ts diff --git a/solutions/typescript/space-age/1/space-age.ts b/solutions/typescript/space-age/1/space-age.ts new file mode 100644 index 0000000..17232aa --- /dev/null +++ b/solutions/typescript/space-age/1/space-age.ts @@ -0,0 +1,28 @@ +type Planets = + | "mercury" + | "venus" + | "earth" + | "mars" + | "jupiter" + | "saturn" + | "uranus" + | "neptune"; + +type EarthYears = { + [Key in Planets]: number; +}; + +const earthYears: EarthYears = { + mercury: 0.2408467, + venus: 0.61519726, + earth: 1.0, + mars: 1.8808158, + jupiter: 11.862615, + saturn: 29.447498, + uranus: 84.016846, + neptune: 164.79132, +}; + +export function age(planet: Planets, seconds: number): number { + return +(seconds / (earthYears[planet] * 31_557_600)).toFixed(2); +}