diff --git a/.gitignore b/.gitignore index 496ee2ca6a..e43b0f9889 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -.DS_Store \ No newline at end of file +.DS_Store diff --git a/arrays/exercises/part-five-arrays.js b/arrays/exercises/part-five-arrays.js index 4cdf1bba41..49cecb2924 100644 --- a/arrays/exercises/part-five-arrays.js +++ b/arrays/exercises/part-five-arrays.js @@ -2,10 +2,13 @@ let str = 'In space, no one can hear you code.'; let arr = ['B', 'n', 'n', 5]; //1) Use the split method on the string to identify the purpose of the parameter inside the (). - +let array = str.split(""); +console.log(array); //2) Use the join method on the array to identify the purpose of the parameter inside the (). - +let array2 = arr.join(""); +console.log(array2); //3) Do split or join change the original string/array? - +//no //4) We can take a comma-separated string and convert it into a modifiable array. Try it! Alphabetize the cargoHold string, and then combine the contents into a new string. let cargoHold = "water,space suits,food,plasma sword,batteries"; +console.log(cargoHold.split(',').sort().join(',')); \ No newline at end of file diff --git a/arrays/exercises/part-four-arrays.js b/arrays/exercises/part-four-arrays.js index 498149702e..3dcd2d9883 100644 --- a/arrays/exercises/part-four-arrays.js +++ b/arrays/exercises/part-four-arrays.js @@ -4,7 +4,16 @@ let holdCabinet2 = ['orange drink', 'nerf toys', 'camera', 42, 'parsnip']; //Explore the methods concat, slice, reverse, and sort to determine which ones alter the original array. //1) Print the result of using concat on the two arrays. Does concat alter the original arrays? Verify this by printing holdCabinet1 after using the method. - +holdCabinet1.concat(); +holdCabinet2.concat(); +console.log(holdCabinet1.concat(holdCabinet2)); //2) Print a slice of two elements from each array. Does slice alter the original arrays? - +holdCabinet1.slice(1,2); +holdCabinet2.slice(0,1); +console.log(holdCabinet1); +console.log(holdCabinet2) //3) reverse the first array, and sort the second. What is the difference between these two methods? Do the methods alter the original arrays? +holdCabinet1.reverse(); +holdCabinet2.sort(); +console.log(holdCabinet1); +console.log(holdCabinet2); \ No newline at end of file diff --git a/arrays/exercises/part-one-arrays.js b/arrays/exercises/part-one-arrays.js index 85a27f5537..60a0261ec1 100644 --- a/arrays/exercises/part-one-arrays.js +++ b/arrays/exercises/part-one-arrays.js @@ -1,5 +1,12 @@ //Create an array that can hold 4 items name practiceFile. +let practiceFile = ["Owl", "Josie", "Bear", "Murdoch"]; //Use the bracket notation method to add "42" and "hello" to the array. Add these new items one at a time. Print the array after each step to confirm the changes. +practiceFile.push(42)[0]; +console.log(practiceFile); +practiceFile.push("hello")[0]; +console.log(practiceFile); //Use a SetValue to add the items "false", and "-4.6" to the array. Print the array to confirm the changes. +practiceFile.push(false, -4.6); +console.log(practiceFile); \ No newline at end of file diff --git a/arrays/exercises/part-six-arrays.js b/arrays/exercises/part-six-arrays.js index d0a28bed56..13f9fc9c77 100644 --- a/arrays/exercises/part-six-arrays.js +++ b/arrays/exercises/part-six-arrays.js @@ -1,11 +1,23 @@ //Arrays can hold different data types, even other arrays! A multi-dimensional array is one with entries that are themselves arrays. //1) Define and initialize the arrays specified in the exercise to hold the name, chemical symbol and mass for different elements. - +let element1 = ['hydrogen', 'H', 1.008]; +let element2 = ['helium', 'He', 4.003]; +let element26 = ['iron', 'Fe', 55.85]; //2) Define the array 'table', and use 'push' to add each of the element arrays to it. Print 'table' to see its structure. +let table = []; +table.push(['hydrogen', 'H', 1.008]); +table.push(['helium', 'He', 4.003]); +table.push(['iron', 'Fe', 55.85]); //3) Use bracket notation to examine the difference between printing 'table' with one index vs. two indices (table[][]). - +console.log(table[1], table[1][1]); //4) Using bracket notation and the table array, print the mass of element1, the name for element 2 and the symbol for element26. - +console.log(table[0][2], table[1][0], table[2][1]); //5) 'table' is an example of a 2-dimensional array. The first “level” contains the element arrays, and the second level holds the name/symbol/mass values. Experiment! Create a 3-dimensional array and print out one entry from each level in the array. +let dogs = [ + ["Bear", "German Shepherd", "Male"], + ["Owl", "Border Collie X", "Male"], + ["Murdoch", "Dachshund", "Male"], + ]; +console.log(dogs[1][1], dogs[2][0], dogs[0][0]); \ No newline at end of file diff --git a/arrays/exercises/part-three-arrays.js b/arrays/exercises/part-three-arrays.js index d43918a702..d50a9daeb2 100644 --- a/arrays/exercises/part-three-arrays.js +++ b/arrays/exercises/part-three-arrays.js @@ -3,7 +3,11 @@ let cargoHold = [1138, 'space suits', 'parrot', 'instruction manual', 'meal pack //Use splice to make the following changes to the cargoHold array. Be sure to print the array after each step to confirm your updates. //1) Insert the string 'keys' at index 3 without replacing any other entries. - +cargoHold.splice(3, 0, "keys"); +console.log(cargoHold); //2) Remove ‘instruction manual’ from the array. (Hint: indexOf is helpful to avoid manually counting an index). - +cargoHold.splice(3, 1); +console.log(cargoHold); //3) Replace the elements at indexes 2 - 4 with the items ‘cat’, ‘fob’, and ‘string cheese’. +cargoHold.splice(2, 3, "cat", "fob","string cheese"); +console.log(cargoHold); \ No newline at end of file diff --git a/arrays/exercises/part-two-arrays.js b/arrays/exercises/part-two-arrays.js index a940b1d0ff..84503fab8d 100644 --- a/arrays/exercises/part-two-arrays.js +++ b/arrays/exercises/part-two-arrays.js @@ -1,11 +1,17 @@ let cargoHold = ['oxygen tanks', 'space suits', 'parrot', 'instruction manual', 'meal packs', 'slinky', 'security blanket']; //1) Use bracket notation to replace ‘slinky’ with ‘space tether’. Print the array to confirm the change. - +cargoHold[5] = 'space tether'; +console.log(cargoHold); //2) Remove the last item from the array with pop. Print the element removed and the updated array. - +cargoHold.pop(); +console.log(cargoHold, "security blanket"); //3) Remove the first item from the array with shift. Print the element removed and the updated array. - +cargoHold.shift(); +console.log(cargoHold, "oxygen tanks"); //4) Unlike pop and shift, push and unshift require arguments inside the (). Add the items 1138 and ‘20 meters’ to the the array - the number at the start and the string at the end. Print the updated array to confirm the changes. - +cargoHold.push("20 Meters"); +cargoHold.unshift(1138); +console.log(cargoHold); //5) Use a template literal to print the final array and its length. +console.log(`The cargoHold string is ` + cargoHold.length + " elements long!"); \ No newline at end of file diff --git a/arrays/studio/multi-dimensional-arrays.js b/arrays/studio/multi-dimensional-arrays.js index 18761a8934..f3f386ecfc 100644 --- a/arrays/studio/multi-dimensional-arrays.js +++ b/arrays/studio/multi-dimensional-arrays.js @@ -4,11 +4,57 @@ let pets = "parrots,cats,moose,alien eggs"; let sleepAids = "blankets,pillows,eyepatches,alarm clocks"; //1) Use split to convert the strings into four cabinet arrays. Alphabetize the contents of each cabinet. - +let newFood = food.split().sort(); +let newEquipment = equipment.split().sort(); +let newPets = pets.split().sort(); +let newSleepAids = sleepAids.split().sort(); +console.log(newFood, newEquipment, newPets, newSleepAids); //2) Initialize a cargoHold array and add the cabinet arrays to it. Print cargoHold to verify its structure. +let cargoHold = [ + [newEquipment], + [newFood], + [newPets], + [newSleepAids] +] +console.log(cargoHold); //3) Query the user to select a cabinet (0 - 3) in the cargoHold. +const input = require('readline-sync'); +let userInput = input.question("Please input a cabinet number (0-3): "); //4) Use bracket notation and a template literal to display the contents of the selected cabinet. If the user entered an invalid number, print an error message. +//tfw you didn't read the question + +switch (userInput ) { + case 0: + userInput === 0 + console.log("Cabinet 0 contains: " + [food]); + break; + case 1: + userInput === 1 + console.log("Cabinet 1 contains: " + [equipment]); + break; + case 2: + userInput === 2 + console.log("Cabinet 2 contains: " + [pets]); + break; + case 3: + userInput === 3 + console.log("Cabinet 3 contains: " + [sleepAids]); + break; + default: + console.log("Invalid cabinet number!"); +} +/*if (userInput === 0) { + console.log(pets); +} else if (userInput === 1) { + console.log(equipment); +} else if (userInput === 2) { + console.log(food); +} else if (userInput === 3) { + console.log(sleepAids); +} else { + console.log("Invalid cabinet selected"); +};*/ //5) Modify the code to query the user for BOTH a cabinet in cargoHold AND a particular item. Use the 'includes' method to check if the cabinet contains the selected item, then print “Cabinet ____ DOES/DOES NOT contain ____.” diff --git a/arrays/studio/string-modification.js b/arrays/studio/string-modification.js index 45991b15fc..b4aab0e030 100644 --- a/arrays/studio/string-modification.js +++ b/arrays/studio/string-modification.js @@ -3,9 +3,18 @@ let str = "LaunchCode"; //1) Use string methods to remove the first three characters from the string and add them to the end. //Hint - define another variable to hold the new string or reassign the new string to str. +let newString = str.slice(3) + str.slice(0,3); +console.log(newString) //Use a template literal to print the original and modified string in a descriptive phrase. +console.log(`Previously, the string was ${str}. Now it is ${newString}`); //2) Modify your code to accept user input. Query the user to enter the number of letters that will be relocated. +let userInput = input.question("How many letters will be rearrange?"); //3) Add validation to your code to deal with user inputs that are longer than the word. In such cases, default to moving 3 characters. Also, the template literal should note the error. +if ( userInput === "three" || 3) { + console.log("Correct!"); +} else { + console.log("Your answer was longer than the correct response"); +}; \ No newline at end of file diff --git a/booleans-and-conditionals/exercises/part-1.js b/booleans-and-conditionals/exercises/part-1.js index b829140a07..1bb3dc699e 100644 --- a/booleans-and-conditionals/exercises/part-1.js +++ b/booleans-and-conditionals/exercises/part-1.js @@ -1,4 +1,11 @@ // 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: diff --git a/booleans-and-conditionals/exercises/part-2.js b/booleans-and-conditionals/exercises/part-2.js index ff11fbab8a..f5f7850934 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) { + 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! Computer 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..80d5429e59 100644 --- a/booleans-and-conditionals/exercises/part-3.js +++ b/booleans-and-conditionals/exercises/part-3.js @@ -17,8 +17,28 @@ e) If fuelLevel is below 1000 OR engineTemperature is above 3500 OR engineIndica f) Otherwise, print "Fuel and engine status pending..." */ // Code 5a - 5f here: +if (fuelLevel < 1000 || engineTemperature > 3500 || engineIndicatorLight === "red blinking"){ + console.log("Engine Failure Imminent!"); +} else if (fuelLevel <= 5000 || engineTemperature > 2500){ + console.log("Check fuel level. Engine running hot."); +} else if (fuelLevel > 20000 && engineTemperature <= 2500){ + console.log("Full tank. Engines are 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...") +} // 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. +let commandOverride = true /* 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!" */ + +if (fuelLevel > 20000 && engineTemperature == "" || commandOverride === true){ + console.log("Cleared to launch!"); +} else { + console.log("Launch scrubbed!"); +} diff --git a/booleans-and-conditionals/studio/data-variables-conditionals.js b/booleans-and-conditionals/studio/data-variables-conditionals.js index 6a15e146f4..e4b6fb4443 100644 --- a/booleans-and-conditionals/studio/data-variables-conditionals.js +++ b/booleans-and-conditionals/studio/data-variables-conditionals.js @@ -1,15 +1,69 @@ // Initialize Variables below +let date = "Monday 2019-03-18" +let time = "10:05:34 AM" +let astronautCount = 7 +let astronautStatus = "ready" +let averageAstronautMassKg = 80.7 +let crewMassKg = astronautCount * averageAstronautMassKg +let fuelMassKg = 760000 +let shuttleMassKg = 74842.31 +let totalMassKg = crewMassKg + fuelMassKg + shuttleMassKg +let maximumMassLimit = 850000 +let fuelTempCelsius = -225 +let minimumFuelTemp = -300 +let maximumFuelTemp = -150 +let fuelLevel = "100%" +let weatherStatus = "clear" +let preparedForLiftOff = true + +console.log(`Today is ${date}. The time is ${time}.`); +console.log(" "); // add logic below to verify total number of astronauts for shuttle launch does not exceed 7 +if (astronautCount <= 7) { + console.log("Astronaut count does not exceed 7!"); +} else { + console.log("Astronaut count exceeds 7!"); +} // add logic below to verify all astronauts are ready +if (astronautStatus === "ready") { + console.log("Astronauts are ready for liftoff!"); +} else { + console.log("Astronauts are not prepared for liftoff!"); +} // add logic below to verify the total mass does not exceed the maximum limit of 850000 +if (totalMassKg > 850000) { + console.log("Weight limit exceeded!"); +} else { + console.log("Within safe weight capacities."); +} // add logic below to verify the fuel temperature is within the appropriate range of -150 and -300 +if (fuelTempCelsius >= -150 && fuelTempCelsius <= -300) { + console.log("Fuel temp is within appropriate ranges of -150 and -300."); +} else { + console.log("Fuel temp is exceeding safe temperature ranges."); +} // add logic below to verify the fuel level is at 100% +if (fuelLevel === "100%") { + console.log("Fuel is at 100% capacity."); +} else { + console.log("Fuel temp is not at 100%"); +} // add logic below to verify the weather status is clear +if (weatherStatus === "clear") { + console.log(`Weather is ${weatherStatus}!`); +} else { + console.log(`Weather status unknown.`); +} // Verify shuttle launch can proceed based on above conditions +if (astronautCount === 7 && astronautStatus === "ready" && fuelTempCelsius >= -150 && fuelTempCelsius <= -300 && fuelLevel === "100%" && weatherStatus === "clear") { + console.log("Ready for takeoff!"); +} else { + console.log("Unable to Launch. Please resolve outstanding launch issues."); +} diff --git a/data-and-variables/exercises/data-and-variables-exercises.js b/data-and-variables/exercises/data-and-variables-exercises.js index 6433bcd641..24d74873dc 100644 --- a/data-and-variables/exercises/data-and-variables-exercises.js +++ b/data-and-variables/exercises/data-and-variables-exercises.js @@ -1,11 +1,30 @@ // Declare and assign the variables below +let nameShuttle = 'Determination'; +let speedShuttle = 17500; +let marsDistanceKm = 225000000; +let moonDistanceKm = 384400; +const milesPerKm = 0.621; // Use console.log to print the 'typeof' each variable. Print one item per line. +console.log(typeof(nameShuttle)); +console.log(typeof(speedShuttle)); +console.log(typeof(marsDistanceKm)); +console.log(typeof(moonDistanceKm)); +console.log(typeof(milesPerKm)); + // Calculate a space mission below +let distanceToMars = marsDistanceKm * milesPerKm +let tripDurationMars = distanceToMars / speedShuttle +let daysToMars = tripDurationMars // Print the results of the space mission calculations below +console.log(`${nameShuttle} will take ${daysToMars} days to reach Mars.`); // Calculate a trip to the moon below +let distanceToMoon = moonDistanceKm * milesPerKm +let tripDurationMoon = distanceToMoon / speedShuttle +let daysToMoon = tripDurationMoon -// Print the results of the trip to the moon below \ No newline at end of file +// Print the results of the trip to the moon below +console.log(`${nameShuttle} will take ${daysToMoon} days to reach the Moon.`) \ No newline at end of file diff --git a/dom-and-events/exercises/script.js b/dom-and-events/exercises/script.js index de6b630519..022d3a4b4b 100644 --- a/dom-and-events/exercises/script.js +++ b/dom-and-events/exercises/script.js @@ -4,6 +4,13 @@ function init () { const paragraph = document.getElementById("statusReport"); // Put your code for the exercises here. + button.addEventListener('click', event => { + paragraph.innerHTML = 'Houston! We have liftoff!'; + }); + + missionAbort.addEventListener("mouseout", function( event ) { + event.target.style.backgroundColor = ""; + }); } diff --git a/dom-and-events/studio/scripts.js b/dom-and-events/studio/scripts.js index 45c9b3a9d1..76324d2c46 100644 --- a/dom-and-events/studio/scripts.js +++ b/dom-and-events/studio/scripts.js @@ -1,2 +1,101 @@ // Write your JavaScript code here. // Remember to pay attention to page loading! + +window.addEventListener('load', function() { + // Wait for all elements to load before attaching event handlers + // This gets references to the necessary elements + const flightStatus = document.getElementById("flightStatus"); + const shuttleBackground = document.getElementById("shuttleBackground"); + const spaceShuttleHeight = document.getElementById("spaceShuttleHeight"); + const takeoffButton = document.getElementById("takeoff"); + const landButton = document.getElementById("landing"); + const abortButton = document.getElementById("missionAbort"); + const upButton = document.getElementById("up"); + const downButton = document.getElementById("down"); + const rocket = document.getElementById("rocket"); + const leftButton = document.getElementById("left"); + const rightButton = document.getElementById("right"); + + // Attaches an event listener to the "Take off" button + takeoffButton.addEventListener('click', function() { + // Uses window.confirm to get user confirmation + const isReadyForTakeoff = window.confirm("Confirm that the shuttle is ready for takeoff."); + + if (isReadyForTakeoff) { + // Updates flight status + flightStatus.innerHTML = "Shuttle in flight"; + + // Changes the background color to blue + shuttleBackground.style.backgroundColor = "blue"; + + // Increases shuttle height by 10,000 miles + const currentHeight = parseInt(spaceShuttleHeight.innerText, 10); + spaceShuttleHeight.innerText = (currentHeight + 10000) + " miles"; + } +}); + + // Attached an event listener to the "Land" button + landButton.addEventListener('click', function() { + window.alert("The shuttle is landing. Landing gear engaged."); + flightStatus.innerHTML = "The shuttle has landed"; + shuttleBackground.style.backgroundColor = "green"; + spaceShuttleHeight.innerText = "0 miles"; + }); + + // Attached an event listener to the "Abort Mission" button + abortButton.addEventListener('click', function() { + const confirmAbort = window.confirm("Confirm that you want to abort the mission."); + if (confirmAbort) { + flightStatus.innerHTML = "Mission aborted"; + shuttleBackground.style.backgroundColor = "green"; + spaceShuttleHeight.innerText = "0 miles"; + } + }); + + // Attach event listeners to directional buttons + //upButton + upButton.addEventListener('click', function() { + moveRocket(0, -10); + updateShuttleHeight(10000); + }); + + //downButton + downButton.addEventListener('click', function() { + moveRocket(0, 10); + updateShuttleHeight(-10000); + }); + + //leftButton + leftButton.addEventListener('click', function() { + console.log("Left button clicked"); + moveRocket(-10, 0); + //x is ACROSS, - + }); + + //rightButton + rightButton.addEventListener('click', function() { + console.log("Right button clicked"); + moveRocket(10, 0); + //x is ACROSS, + + }); + + + function moveRocket(dx, dy) { + // Calculates new position for the rocket image + const rocketStyle = getComputedStyle(rocket); + const rocketX = parseInt(rocketStyle.left, 10) + dx; + const rocketY = parseInt(rocketStyle.top, 10) + dy; + + // Updates the rocket's position + // Using X/Y to differentiate, (X, Y) + rocket.style.left = rocketX + "px"; + rocket.style.top = rocketY + "px"; + } + + function updateShuttleHeight(change) { + const currentHeight = parseInt(spaceShuttleHeight.innerText, 10); + spaceShuttleHeight.innerText = (currentHeight + change) + " miles"; + } +}); + + diff --git a/errors-and-debugging/exercises/Debugging1stSyntaxError.js b/errors-and-debugging/exercises/Debugging1stSyntaxError.js index 365af5a964..88c524a4ab 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..98c415492f 100644 --- a/errors-and-debugging/exercises/DebuggingLogicErrors2.js +++ b/errors-and-debugging/exercises/DebuggingLogicErrors2.js @@ -16,7 +16,7 @@ if (fuelLevel >= 20000) { console.log('WARNING: Insufficient fuel!'); launchReady = false; } - +console.log(launchReady) // if (crewStatus && computerStatus === 'green'){ // console.log('Crew & computer cleared.'); // launchReady = true; diff --git a/errors-and-debugging/exercises/DebuggingLogicErrors3.js b/errors-and-debugging/exercises/DebuggingLogicErrors3.js index 023f2ab07d..3a1fe650bc 100644 --- a/errors-and-debugging/exercises/DebuggingLogicErrors3.js +++ b/errors-and-debugging/exercises/DebuggingLogicErrors3.js @@ -25,7 +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...'); // console.log('Liftoff!'); diff --git a/errors-and-debugging/exercises/DebuggingLogicErrors5.js b/errors-and-debugging/exercises/DebuggingLogicErrors5.js index 7eb908e769..c276b0e89c 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,19 @@ 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); + +//Textbook said to add a countdown? +const countDown = number => [...Array(number + 1).keys()].reverse(); + +if (crewReady === true && launchReady === true){ + console.log(countDown(9)) +} else { + console.log("Launch scrubbed!") +}; \ No newline at end of file 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..e69de29bb2 100644 --- a/errors-and-debugging/exercises/DebuggingRuntimeErrors2.js +++ b/errors-and-debugging/exercises/DebuggingRuntimeErrors2.js @@ -1,21 +0,0 @@ -let launchReady = false; -let fuelLevel = 27000; - -if (fuelLevel >= 20000) { - console.log('Fuel level cleared.'); - launchReady = true; -} else { - console.log('WARNING: Insufficient fuel!'); - launchReady = false; -} - -if (launchReady) { - console.log("10, 9, 8..."); - console.log("Fed parrot..."); - console.log("6, 5, 4..."); - console.log("Ignition..."); - consoul.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!"); diff --git a/fetch/exercise/fetch_planets.html b/fetch/exercise/fetch_planets.html new file mode 100644 index 0000000000..0272caecc3 --- /dev/null +++ b/fetch/exercise/fetch_planets.html @@ -0,0 +1,31 @@ + + +
+