space-age.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
var SpaceAge = function(seconds) {
  var planetYears = function(earthYears) {
    var years = seconds / (31557600.0 * earthYears);
    return Math.round(years * 100) / 100;
  };

  return {
    seconds: seconds,

    onEarth: function()   { return planetYears(1.0); },
    onMercury: function() { return planetYears(0.2408467); },
    onVenus: function()   { return planetYears(0.61519726); },
    onMars: function()    { return planetYears(1.8808158); },
    onJupiter: function() { return planetYears(11.862615); },
    onSaturn: function()  { return planetYears(29.447498); },
    onUranus: function()  { return planetYears(84.016846); },
    onNeptune: function() { return planetYears(164.79132); }
  };
};

module.exports = SpaceAge;

Comments


You're not logged in right now. Please login via GitHub to comment