Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8c30416

Browse files
author
programmiri
committed
Apply feedback from exercism for excercise Space Age
1 parent 46d772f commit 8c30416

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

‎space-age/space-age.js‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
const planetMap = {
1+
const BASE_SECONDS = 31557600;
2+
3+
const PLANET_MAP = {
24
earth: 1,
35
mercury: 0.2408467,
46
venus: 0.61519726,
@@ -9,12 +11,9 @@ const planetMap = {
911
neptune: 164.79132,
1012
};
1113

12-
function roundFloat(float, dec) {
13-
return +Number.parseFloat(float).toFixed(dec);
14-
}
14+
const roundFloat = (float, dec) => Number(float.toFixed(dec));
1515

1616
export const age = (planet, seconds) => {
17-
const baseSeconds = 31557600;
18-
const yearsNonRounded = seconds / (baseSeconds * planetMap[planet]);
17+
const yearsNonRounded = seconds / (BASE_SECONDS * PLANET_MAP[planet]);
1918
return roundFloat(yearsNonRounded, 2);
2019
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /