|
1 | 1 | // Initialize Variables below
|
2 | 2 |
|
3 |
| -// add logic below to verify total number of astronauts for shuttle launch does not exceed 7 |
4 | 3 |
|
5 |
| -// add logic below to verify all astronauts are ready |
6 | 4 |
|
7 |
| -// add logic below to verify the total mass does not exceed the maximum limit of 850000 |
| 5 | +let date = "Monday 2019-03-18"; |
| 6 | +let time = "10:05:34 AM"; |
| 7 | +let astronautCount = 7; |
| 8 | +let astronautStatus = "ready"; |
| 9 | +let averageAstronautMassKg = 80.7; |
| 10 | +let crewMassKg = (astronautCount * averageAstronautMassKg); |
| 11 | +let fuelMassKg = 760000; |
| 12 | +let shuttleMassKg = 74842.31; |
| 13 | +let totalMassKg = crewMassKg + fuelMassKg + shuttleMassKg; |
| 14 | +let maximumMassLimit = 850000; |
| 15 | +let fuelTempCelsius = -225; |
| 16 | +let minimumFuelTemp = -300; |
| 17 | +let maximumFuelTemp = -150; |
| 18 | +let fuelLevel = "100%"; |
| 19 | +let weatherStatus = "clear"; |
| 20 | +let preparedForLiftOff = true; |
8 | 21 |
|
| 22 | +// add logic below to verify total number of astronauts for shuttle launch does not exceed 7 |
| 23 | +if (astronautCount > 7) { |
| 24 | + preparedForLiftOff = false; |
| 25 | + console.log("Security alert! Kick " + (astronautCount - 7) + " astronauts off to launch!"); |
| 26 | +} |
| 27 | +// add logic below to verify all astronauts are ready |
| 28 | +if (astronautStatus !== "ready") { |
| 29 | + preparedForLiftOff = false; |
| 30 | + console.log("Somehow, one or more astronaut is not ready????"); |
| 31 | +} |
| 32 | +// add logic below to verify the total mass does not exceed the maximum limit of 850000 |
| 33 | +if (totalMassKg > maximumMassLimit) { |
| 34 | + console.log("Mass exceeds maximum mass limit!"); |
| 35 | + preparedForLiftOff = false; |
| 36 | +} |
9 | 37 | // add logic below to verify the fuel temperature is within the appropriate range of -150 and -300
|
10 |
| - |
| 38 | +if (fuelTempCelsius < minimumFuelTemp || fuelTempCelsius > maximumFuelTemp) { |
| 39 | + console.log("Fuel temperature is not in range - DO NOT LAUNCH!"); |
| 40 | + preparedForLiftOff = false; |
| 41 | +} |
11 | 42 | // add logic below to verify the fuel level is at 100%
|
12 |
| - |
| 43 | +if (fuelLevel !== "100%") { |
| 44 | + preparedForLiftOff = false; |
| 45 | + console.log("Please refuel before launch."); |
| 46 | +} |
13 | 47 | // add logic below to verify the weather status is clear
|
14 |
| - |
| 48 | +if (weatherStatus !== "clear") { |
| 49 | + console.log("Weather is not clear."); |
| 50 | + preparedForLiftOff = false; |
| 51 | +} |
15 | 52 | // Verify shuttle launch can proceed based on above conditions
|
| 53 | +if (!preparedForLiftOff) { |
| 54 | + console.log("ABORT MISSION!"); |
| 55 | +} else { |
| 56 | + console.log(` |
| 57 | + All systems are a go! Initiating space shuttle launch sequence. |
| 58 | + --------------------------------------------------------------- |
| 59 | + Date: ${date} |
| 60 | + Time: ${time} |
| 61 | + Astronaut Count: ${astronautCount} |
| 62 | + Crew Mass: ${crewMassKg} kg |
| 63 | + Fuel Mass: ${fuelMassKg} kg |
| 64 | + Shuttle Mass: ${shuttleMassKg} kg |
| 65 | + Total Mass: ${totalMassKg} kg |
| 66 | + Fuel Temperature: ${fuelTempCelsius} C |
| 67 | + Weather Status: ${weatherStatus} |
| 68 | + --------------------------------------------------------------- |
| 69 | + Have a safe trip astronauts!`); |
| 70 | +} |
| 71 | + |
| 72 | + |
0 commit comments