Browse Source

new exercise for data

pull/554/head
MSilva95 4 years ago committed by Clément
parent
commit
842d39f9dd
  1. 13
      js/tests/dog-years_test.js
  2. 21
      subjects/dog-years.en.md

13
js/tests/dog-years_test.js

@ -0,0 +1,13 @@
export const tests = []
const t = (f) => tests.push(f)
t(({ eq }) => eq(dogYears('earth', 1000000000), 221.82))
t(({ eq }) => eq(dogYears('mercury', 2134835688), 1966.16))
t(({ eq }) => eq(dogYears('venus', 189839836), 68.45))
t(({ eq }) => eq(dogYears('mars', 2129871239), 251.19))
t(({ eq }) => eq(dogYears('jupiter', 901876382), 16.86))
t(({ eq }) => eq(dogYears('saturn', 2000000000), 15.07))
t(({ eq }) => eq(dogYears('uranus', 1210123456), 3.19))
t(({ eq }) => eq(dogYears('neptune', 1821023456), 2.45))
Object.freeze(tests)

21
subjects/dog-years.en.md

@ -0,0 +1,21 @@
## Dog Years
### Instructions
Someone once said that a dog makes 7 years for each human year.
Create a `dogYears` function that if given a planet name and an age in seconds,
calculates how old a dog would be on the given planet.
- Earth: orbital period 1.0 Earth years, 365.25 Earth days, or 31,557,600 seconds
- Mercury: orbital period 0.2408467 Earth years
- Venus: orbital period 0.61519726 Earth years
- Mars: orbital period 1.8808158 Earth years
- Jupiter: orbital period 11.862615 Earth years
- Saturn: orbital period 29.447498 Earth years
- Uranus: orbital period 84.016846 Earth years
- Neptune: orbital period 164.79132 Earth years
So if you were told someone that their dog were 1,000,000,000 seconds old, you should be able to say that the dog is 221.83 Earth-years old.
You will have to format the number so that the result is rounded like the example above.
Loading…
Cancel
Save