You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

exercise_1.js 1.0KB

123456789101112131415161718192021222324252627282930
  1. 'use strict'
  2. let shuttleName = 'Determination';
  3. let shuttleSpeedMph = 17_500;
  4. const DISTANCE_TO_MARS_KM = 225_000_000;
  5. const DISTANCE_TO_MOON_KM = 384_400;
  6. const MILES_PER_KM = 0.621;
  7. const HOURS_PER_DAY = 24;
  8. console.log(typeof shuttleName);
  9. console.log(typeof shuttleSpeedMph);
  10. console.log(typeof DISTANCE_TO_MARS_KM);
  11. console.log(typeof DISTANCE_TO_MOON_KM);
  12. console.log(typeof MILES_PER_KM);
  13. let milesToMars = DISTANCE_TO_MARS_KM * MILES_PER_KM;
  14. let hoursToMars = milesToMars / shuttleSpeedMph;
  15. let daysToMars = hoursToMars / HOURS_PER_DAY;
  16. let milesToMoon = DISTANCE_TO_MOON_KM * MILES_PER_KM;
  17. let hoursToMoon = milesToMoon / shuttleSpeedMph;
  18. let daysToMoon = hoursToMoon / HOURS_PER_DAY;
  19. console.log(shuttleName + ' will take ' + daysToMars.toFixed(2) + ' days to reach Mars ');
  20. /*
  21. console.log('${shuttleName} will take ${daysToMars} days to reach Mars'); kan ook.
  22. .toFixed() verandert de primitive value van daysToMars naar een object.
  23. */
  24. console.log(shuttleName + ' will take ' + daysToMoon.toFixed(2) + ' days to reach the Moon ');