We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 46d772f commit 8c30416Copy full SHA for 8c30416
space-age/space-age.js
@@ -1,4 +1,6 @@
1
-const planetMap = {
+const BASE_SECONDS = 31557600;
2
+
3
+const PLANET_MAP = {
4
earth: 1,
5
mercury: 0.2408467,
6
venus: 0.61519726,
@@ -9,12 +11,9 @@ const planetMap = {
9
11
neptune: 164.79132,
10
12
};
13
-function roundFloat(float, dec) {
- return +Number.parseFloat(float).toFixed(dec);
14
-}
+const roundFloat = (float, dec) => Number(float.toFixed(dec));
15
16
export const age = (planet, seconds) => {
17
- const baseSeconds = 31557600;
18
- const yearsNonRounded = seconds / (baseSeconds * planetMap[planet]);
+ const yearsNonRounded = seconds / (BASE_SECONDS * PLANET_MAP[planet]);
19
return roundFloat(yearsNonRounded, 2);
20
0 commit comments