diff --git a/booleans-and-conditionals/exercises/part-1.js b/booleans-and-conditionals/exercises/part-1.js index b829140a07..427e629f3b 100644 --- a/booleans-and-conditionals/exercises/part-1.js +++ b/booleans-and-conditionals/exercises/part-1.js @@ -1,6 +1,17 @@ // Declare and initialize the variables for exercise 1 here: +let engineIndicatorLight = "red blinking"; +let spaceSuitsOn = true; +let shuttleCabinReady = true; +let crewStatus = spaceSuitsOn && shuttleCabinReady; +let computerStatusCode = 200; +let shuttleSpeed = 15000; // BEFORE running the code, predict what will be printed to the console by the following statements: +// engines are off +// Crew Not Ready +// Please stand by. Computer is rebooting. +// Stable speed. + if (engineIndicatorLight === "green") { console.log("engines have started"); @@ -9,3 +20,20 @@ if (engineIndicatorLight === "green") { } else { console.log("engines are off"); } + +let fuelLevel = 18000; +let engineTemperature = 2500; + +if (fuelLevel < 1000 || engineTemperature > 3500 || engineIndicatorLight === "red blinking"){ + console.log("ENGINE FAILURE IMMINENT!"); +} else if (fuelLevel <= 5000 || engineTemperature > 2500){ + console.log("Check fuel level. Engines running hot."); +} else if (fuelLevel > 20000 && engineTemperature <= 2500){ + console.log("Full tank. Engines good."); +} else if (fuelLevel > 10000 && engineTemperature <= 2500){ + console.log("Fuel level above 50%. Engines good."); +} else if (fuelLevel > 5000 && engineTemperature <= 2500){ + console.log("Fuel level above 25%. Engines good."); +} else { + console.log("Fuel and engine status pending..."); +} diff --git a/booleans-and-conditionals/exercises/part-2.js b/booleans-and-conditionals/exercises/part-2.js index ff11fbab8a..61bb8d508a 100644 --- a/booleans-and-conditionals/exercises/part-2.js +++ b/booleans-and-conditionals/exercises/part-2.js @@ -8,14 +8,30 @@ let shuttleSpeed = 15000; // 3) Write conditional expressions to satisfy the following safety rules: // a) If crewStatus is true, print "Crew Ready" else print "Crew Not Ready". - +if (crewStatus === true) { + console.log("Crew Ready."); +} else { + console.log("Crew Not Ready.") +} // b) If computerStatusCode is 200, print "Please stand by. Computer is rebooting." Else if computerStatusCode is 400, print "Success! Computer online." Else print "ALERT: Computer offline!" - +if (computerStatusCode === 200) { + console.log("Please stand by. Computer is rebooting."); +} else if (computerStatusCode === 400) { + console.log("Success! Comouter online."); +} else { + console.log("ALERT: Computer offline!"); +} // c) If shuttleSpeed is > 17,500, print "ALERT: Escape velocity reached!" Else if shuttleSpeed is < 8000, print "ALERT: Cannot maintain orbit!" Else print "Stable speed". - +if (shuttleSpeed > 17500) { + console.log("ALERT: Escape velocity reached!"); +} else if (shuttleSpeed < 8000) { + console.log("ALERT: Cannot maintain orbit!"); +} else { + console.log("Stable speed."); +} // 4) PREDICT: Do the code blocks shown in the 'predict.txt' file produce the same result? -console.log(/* "Yes" or "No" */); +console.log("Yes"); diff --git a/booleans-and-conditionals/exercises/part-3.js b/booleans-and-conditionals/exercises/part-3.js index 9ed686d097..3f8b7f5208 100644 --- a/booleans-and-conditionals/exercises/part-3.js +++ b/booleans-and-conditionals/exercises/part-3.js @@ -18,7 +18,27 @@ f) Otherwise, print "Fuel and engine status pending..." */ // Code 5a - 5f here: +if (fuelLevel > 20000 && engineTemperature <= 2500) { + console.log("Full tank. Engines good.") +} else if (fuelLevel > 10000 && engineTemperature <= 2500) { + console.log("Fuel level above 50%. Engines good."); +} else if (fuelLevel > 5000 && engineTemperature <= 2500) { + console.log("Fuel above 25%. Engines good."); +} else if (fuelLevel <= 5000 || engineTemperature > 2500) { + console.log("Check fuel level. Engines running hot."); +} else if (fuelLevel < 1000 || engineTemperature > 3500 || engineIndicatorLight === "red blinking") { + console.log("ENGINE FAILURE IMMINENT!"); +} else { + console.log("Fuel and engine status pending..."); +} + // 6) a) Create the variable commandOverride, and set it to be true or false. If commandOverride is false, then the shuttle should only launch if the fuel and engine check are OK. If commandOverride is true, then the shuttle will launch regardless of the fuel and engine status. /* 6) b) Code the following if/else check: If fuelLevel is above 20000 AND engineIndicatorLight is NOT red blinking OR commandOverride is true print "Cleared to launch!" Else print "Launch scrubbed!" */ +let commandOverride = false +if (fuelLevel > 20000 && engineIndicatorLight != "red blinking" || commandOverride === true) { + console.log("Cleared to launch!"); +} else { + console.log("Launch scrubbed!"); +} \ No newline at end of file diff --git a/booleans-and-conditionals/studio/data-variables-conditionals.js b/booleans-and-conditionals/studio/data-variables-conditionals.js index 6a15e146f4..7677eb2c83 100644 --- a/booleans-and-conditionals/studio/data-variables-conditionals.js +++ b/booleans-and-conditionals/studio/data-variables-conditionals.js @@ -1,15 +1,50 @@ // Initialize Variables below +const date = "Monday 2019-03-18" +const time = "10:05:34 AM" +const astronautCount = 7 +const astronautStatus = "ready" +const averageAstronautMassKg = 80.7 +const crewMassKg = (astronautCount * averageAstronautMassKg) +const fuelMassKg = 760000 +const shuttleMassKg = 74842.31 +const totalMassKg = (crewMassKg + fuelMassKg + shuttleMassKg) +const maximumMassLimit = 850000 +const fuelTempCelcius = -225 +const minimumFuelTemp = -300 +const maximumFuelTemp = -150 +let fuelLevel = "100%" +let weatherStatus = "clear" +let preparedForLiftOff = true // add logic below to verify total number of astronauts for shuttle launch does not exceed 7 +if (astronautCount <= 7); // add logic below to verify all astronauts are ready +if (astronautStatus === "ready"); // add logic below to verify the total mass does not exceed the maximum limit of 850000 +if (totalMassKg < maximumMassLimit); // add logic below to verify the fuel temperature is within the appropriate range of -150 and -300 +if (fuelTempCelcius >= minimumFuelTemp || maximumFuelTemp); // add logic below to verify the fuel level is at 100% +if (fuelLevel === "100%"); // add logic below to verify the weather status is clear +if (weatherStatus === "clear"){ + console.log("All systems are a go! Initiating space shuttle launch sequence."); +} // Verify shuttle launch can proceed based on above conditions +console.log("date: " + date); +console.log("time: " + time); +console.log("Astronaut Count: " + astronautCount); +console.log("Crew Mass: " + crewMassKg + " kg"); +console.log("Fuel Mass: " + fuelMassKg + " kg"); +console.log("Shuttle Mass: " + shuttleMassKg + " kg"); +console.log("Total Mass: " + totalMassKg + " kg"); +console.log("Fuel Temperature: " + fuelTempCelcius + " C"); +console.log("Weather Status: " + weatherStatus); + +console.log("Have a safe trip astronauts!") diff --git a/data-and-variables/exercises/data-and-variables-exercises.js b/data-and-variables/exercises/data-and-variables-exercises.js index 6433bcd641..3e20b66ca6 100644 --- a/data-and-variables/exercises/data-and-variables-exercises.js +++ b/data-and-variables/exercises/data-and-variables-exercises.js @@ -1,11 +1,24 @@ // Declare and assign the variables below - +let shuttleName = "Determination"; +let shuttleSpeedMph = 17500; +let distanceToMarsKm = 225000000; +let distanceToMoonKm = 38400; +const milesPerKm = 0.621; // Use console.log to print the 'typeof' each variable. Print one item per line. - +console.log(typeof shuttleName); +console.log(typeof shuttleSpeedMph); +console.log(typeof distanceToMarsKm); +console.log(typeof distanceToMoonKm); +console.log(typeof milesPerKm); // Calculate a space mission below - +let milesToMars = distanceToMarsKm * milesPerKm; +let hoursToMars = milesToMars / shuttleSpeedMph; +let daysToMars = hoursToMars / 24; // Print the results of the space mission calculations below - +console.log(shuttleName + "will take " + daysToMars + " days to reach Mars."); // Calculate a trip to the moon below - -// Print the results of the trip to the moon below \ No newline at end of file +let milesToMoon = distanceToMoonKm * milesPerKm; +let hoursToMoon = milesToMoon / shuttleSpeedMph; +let daysToMoon = hoursToMoon / 24; +// Print the results of the trip to the moon below +console.log(shuttleName + "will take" + daysToMoon + "days to reach the Moon.") \ No newline at end of file diff --git a/data-and-variables/exercises/package-lock.json b/data-and-variables/exercises/package-lock.json new file mode 100644 index 0000000000..8f84d79bed --- /dev/null +++ b/data-and-variables/exercises/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "exercises", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/errors-and-debugging/exercises/Debugging1stSyntaxError.js b/errors-and-debugging/exercises/Debugging1stSyntaxError.js index 365af5a964..f35a8c49d2 100644 --- a/errors-and-debugging/exercises/Debugging1stSyntaxError.js +++ b/errors-and-debugging/exercises/Debugging1stSyntaxError.js @@ -4,7 +4,7 @@ let launchReady = false; let fuelLevel = 17000; -if (fuelLevel >= 20000 { +if (fuelLevel >= 20000) { console.log('Fuel level cleared.'); launchReady = true; } else { diff --git a/errors-and-debugging/exercises/DebuggingLogicErrors2.js b/errors-and-debugging/exercises/DebuggingLogicErrors2.js index 160a0c2cd0..b7b59c7682 100644 --- a/errors-and-debugging/exercises/DebuggingLogicErrors2.js +++ b/errors-and-debugging/exercises/DebuggingLogicErrors2.js @@ -16,6 +16,7 @@ if (fuelLevel >= 20000) { console.log('WARNING: Insufficient fuel!'); launchReady = false; } +console.log(launchReady); // if (crewStatus && computerStatus === 'green'){ // console.log('Crew & computer cleared.'); diff --git a/errors-and-debugging/exercises/DebuggingLogicErrors3.js b/errors-and-debugging/exercises/DebuggingLogicErrors3.js index 023f2ab07d..0ba6e61d76 100644 --- a/errors-and-debugging/exercises/DebuggingLogicErrors3.js +++ b/errors-and-debugging/exercises/DebuggingLogicErrors3.js @@ -25,6 +25,7 @@ if (crewStatus && computerStatus === 'green'){ console.log('WARNING: Crew or computer not ready!'); launchReady = false; } +console.log(launchReady); // if (launchReady) { // console.log('10, 9, 8, 7, 6, 5, 4, 3, 2, 1...'); diff --git a/errors-and-debugging/exercises/DebuggingLogicErrors5.js b/errors-and-debugging/exercises/DebuggingLogicErrors5.js index 7eb908e769..adf204bbe8 100644 --- a/errors-and-debugging/exercises/DebuggingLogicErrors5.js +++ b/errors-and-debugging/exercises/DebuggingLogicErrors5.js @@ -3,6 +3,7 @@ // Refactor the code to do this. Verify that your change works by updating the console.log statements. let launchReady = false; +let crewReady = false; let fuelLevel = 17000; let crewStatus = true; let computerStatus = 'green'; @@ -19,10 +20,17 @@ console.log("launchReady = ", launchReady); if (crewStatus && computerStatus === 'green'){ console.log('Crew & computer cleared.'); - launchReady = true; + crewReady = true; } else { console.log('WARNING: Crew or computer not ready!'); - launchReady = false; + crewReady = false; } -console.log("launchReady = ", launchReady); \ No newline at end of file +console.log("crewReady = ", crewReady); + +if (launchReady) { + console.log('10, 9, 8, 7, 6, 5, 4, 3, 2, 1...'); + console.log('Liftoff!'); +} else { + console.log('Launch scrubbed.'); +} diff --git a/errors-and-debugging/exercises/DebuggingRuntimeErrors1.js b/errors-and-debugging/exercises/DebuggingRuntimeErrors1.js index e66e494a30..7bbf7ebb82 100644 --- a/errors-and-debugging/exercises/DebuggingRuntimeErrors1.js +++ b/errors-and-debugging/exercises/DebuggingRuntimeErrors1.js @@ -4,7 +4,7 @@ let launchReady = false; let fuelLevel = 17000; -if (fuellevel >= 20000) { +if (fuelLevel >= 20000) { console.log('Fuel level cleared.'); launchReady = true; } else { diff --git a/errors-and-debugging/exercises/DebuggingRuntimeErrors2.js b/errors-and-debugging/exercises/DebuggingRuntimeErrors2.js index a656080d25..703a0d61c4 100644 --- a/errors-and-debugging/exercises/DebuggingRuntimeErrors2.js +++ b/errors-and-debugging/exercises/DebuggingRuntimeErrors2.js @@ -14,7 +14,7 @@ if (launchReady) { console.log("Fed parrot..."); console.log("6, 5, 4..."); console.log("Ignition..."); - consoul.log("3, 2, 1..."); + console.log("3, 2, 1..."); console.log("Liftoff!"); } else { console.log("Launch scrubbed."); diff --git a/errors-and-debugging/exercises/DebuggingSyntaxErrors2.js b/errors-and-debugging/exercises/DebuggingSyntaxErrors2.js index b600339254..daf36e5da5 100644 --- a/errors-and-debugging/exercises/DebuggingSyntaxErrors2.js +++ b/errors-and-debugging/exercises/DebuggingSyntaxErrors2.js @@ -8,7 +8,7 @@ let launchReady = false; let crewStatus = true; let computerStatus = 'green'; -if (crewStatus &&& computerStatus === 'green'){ +if (crewStatus && computerStatus === 'green'){ console.log('Crew & computer cleared.'); launchReady = true; } else { @@ -17,7 +17,7 @@ if (crewStatus &&& computerStatus === 'green'){ } if (launchReady) { - console.log(("10, 9, 8, 7, 6, 5, 4, 3, 2, 1..."); + console.log("10, 9, 8, 7, 6, 5, 4, 3, 2, 1..."); console.log("Fed parrot..."); console.log("Ignition..."); console.log("Liftoff!");