Browse Source

Data and Variables

master
Bart De Lepeleer 2 years ago
parent
commit
72e34563ad
1 changed files with 26 additions and 0 deletions
  1. 26
    0
      data-and-variables/solution.js

+ 26
- 0
data-and-variables/solution.js View File

@@ -0,0 +1,26 @@
let shuttleName = 'Determination';
let shuttleSpeedMph = 17_500;
const DISTANCE_TO_MARS_KM = 225_000_000;
const DISTANCE_TO_MOON_KM = 384_400;
const MILES_PER_KM = 0.621;
const HOURS_PER_DAY = 24;

console.log(typeof shuttleName);
console.log(typeof shuttleSpeedMph);
console.log(typeof DISTANCE_TO_MARS_KM);
console.log(typeof DISTANCE_TO_MOON_KM);
console.log(typeof MILES_PER_KM);

let milesToMars = DISTANCE_TO_MARS_KM * MILES_PER_KM;
let hoursToMars = milesToMars / shuttleSpeedMph;
let daysToMars = hoursToMars / HOURS_PER_DAY;

//console.log(shuttleName + " will take " + daysToMars + " days to reach Mars");
console.log(`${shuttleName} will take ${daysToMars.toFixed(2)} days to reach Mars`);

let milesToMoon = DISTANCE_TO_MOON_KM * MILES_PER_KM;
let hoursToMoon = milesToMoon / shuttleSpeedMph;
let daysToMoon = hoursToMoon / HOURS_PER_DAY;

//console.log(shuttleName + " will take " + daysToMoon + " days to reach Moon");
console.log(`${shuttleName} will take ${daysToMoon.toFixed(2)} days to reach Moon`);

Loading…
Cancel
Save