From 2e12e243896fd616135f1c1ab5ecb14c76c24ee3 Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Wed, 14 Jan 2026 07:18:48 +0000 Subject: [PATCH] [Sync Iteration] javascript/space-age/1 --- solutions/javascript/space-age/1/space-age.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 solutions/javascript/space-age/1/space-age.js diff --git a/solutions/javascript/space-age/1/space-age.js b/solutions/javascript/space-age/1/space-age.js new file mode 100644 index 0000000..a5f88b4 --- /dev/null +++ b/solutions/javascript/space-age/1/space-age.js @@ -0,0 +1,23 @@ +// +// This is only a SKELETON file for the 'Space Age' exercise. It's been provided as a +// convenience to get you started writing code faster. +// + +export const age = (planet, seconds) => { + let earthSeconds = 31557600; + let planets = { + 'earth': 31557600, + 'mercury': earthSeconds * 0.2408467, + 'venus': earthSeconds * 0.61519726, + 'mars': earthSeconds * 1.8808158, + 'jupiter': earthSeconds * 11.862615, + 'saturn': earthSeconds * 29.447498, + 'uranus': earthSeconds * 84.016846, + 'neptune': earthSeconds * 164.79132, + }; + if (!planets.hasOwnProperty(planet)){ + throw('not a planet') + } + let years = seconds / planets[planet]; + return Number(years.toFixed(2)) +};