diff --git a/arrays/exercises/part-five-arrays.js b/arrays/exercises/part-five-arrays.js index 4cdf1bba41..2ba1081400 100644 --- a/arrays/exercises/part-five-arrays.js +++ b/arrays/exercises/part-five-arrays.js @@ -2,10 +2,20 @@ 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 newArr = []; +newArr = str.split(' '); +console.log(newArr); //2) Use the join method on the array to identify the purpose of the parameter inside the (). - +let newString = ''; +newString = arr.join(''); +console.log(newString); //3) Do split or join change the original string/array? - +console.log(str); +console.log(arr); +console.log("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"; +let arr2 = []; +arr2 = cargoHold.split(',').sort().join(', '); +console.log(arr2); + diff --git a/arrays/exercises/part-four-arrays.js b/arrays/exercises/part-four-arrays.js index 498149702e..120ad3975b 100644 --- a/arrays/exercises/part-four-arrays.js +++ b/arrays/exercises/part-four-arrays.js @@ -4,7 +4,17 @@ 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. - +console.log(holdCabinet1.concat(holdCabinet2)); +console.log(holdCabinet1); +console.log("No."); //2) Print a slice of two elements from each array. Does slice alter the original arrays? - +console.log(holdCabinet1.slice(0, 2) + ", " + holdCabinet2.slice(1,3)); +console.log(holdCabinet1); +console.log(holdCabinet2); +console.log("No."); //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); +console.log("The difference in these methods is that 'reverse' changes the order of elements relative to their original position in the array,\n and 'sort' changes the order of elements according to an inherent logic in JavaScript.") \ No newline at end of file diff --git a/arrays/exercises/part-one-arrays.js b/arrays/exercises/part-one-arrays.js index 92f4e45170..e3b6a41f82 100644 --- a/arrays/exercises/part-one-arrays.js +++ b/arrays/exercises/part-one-arrays.js @@ -1,5 +1,11 @@ //Create an array called practiceFile with the following entry: 273.15 - +let practiceFile = [273.15]; //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[1] = 42; +console.log(practiceFile); +practiceFile[2] = "hello"; +console.log(practiceFile); //Use a single .push() to add the following items: false, -4.6, and "87". Print the array to confirm the changes. +practiceFile.push(false, -4.6, "87", "George Jones", "Hank Jr.", "Willie", "Sturgill"); +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..a33bdc178b 100644 --- a/arrays/exercises/part-six-arrays.js +++ b/arrays/exercises/part-six-arrays.js @@ -1,11 +1,44 @@ //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. +element1 = ['hydrogen', 'H', 1.008]; +element2 = ['helium', 'He', 4.003]; +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. +//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(element1, element2, element26); +console.log(table); //3) Use bracket notation to examine the difference between printing 'table' with one index vs. two indices (table[][]). - +console.log(table[1]); +console.log(table[0][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 foodGroups = ['bbq', 'barbeque', 'asado']; +let meats = ['brisket', 'pork ribs', 'turkey']; +let sides = ['potato salad', 'coleslaw', 'beans']; + +let lastMeal = []; +lastMeal.push(foodGroups, meats, sides); +console.log(lastMeal); + + +let animals = ["bear", "shark", "squirrel"]; +let theory = ["quantum", "multi-verse", "string"]; +let friends = ["Jacob", "Paul", "Jake"]; + +let chaos = []; +chaos.push(animals, theory, friends); +console.log(chaos); + + + +let threeD = []; + +threeD.push(table, lastMeal, chaos); +console.log(threeD); +console.log(threeD[2][1][2]); +console.log(threeD[1][1][2]); +console.log(threeD[0][1][2]); diff --git a/arrays/exercises/part-three-arrays.js b/arrays/exercises/part-three-arrays.js index d43918a702..85c20cbfde 100644 --- a/arrays/exercises/part-three-arrays.js +++ b/arrays/exercises/part-three-arrays.js @@ -3,7 +3,14 @@ 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). - +console.log(cargoHold.indexOf('instruction manual')); //wtf doesn't this work? Returns -1 each time +cargoHold.splice(4, 1); +console.log(cargoHold); //3) Replace the elements at indexes 2 - 4 with the items ‘cat’, ‘fob’, and ‘string cheese’. +cargoHold.splice(2, 1, "cat"); +cargoHold.splice(3, 1, "fob"); +cargoHold.splice(4, 1, "string cheese"); +console.log(cargoHold); diff --git a/arrays/exercises/part-two-arrays.js b/arrays/exercises/part-two-arrays.js index a940b1d0ff..b08f5d7eba 100644 --- a/arrays/exercises/part-two-arrays.js +++ b/arrays/exercises/part-two-arrays.js @@ -1,11 +1,21 @@ 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[6]); //Leaving this here because unsure if purpose of exercise is to demonstrate "undefined" or not// +console.log("security blanket"); +console.log(cargoHold); //3) Remove the first item from the array with shift. Print the element removed and the updated array. - +cargoHold.shift(); +console.log("oxygen tanks"); +console.log(cargoHold[0]); +console.log(cargoHold); //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.unshift(1138); +cargoHold.push("20 meters"); +console.log(cargoHold); //5) Use a template literal to print the final array and its length. +console.log(`The cargo hold contains ${cargoHold.length} items.`); \ 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..1227fe3ac1 100644 --- a/booleans-and-conditionals/exercises/part-1.js +++ b/booleans-and-conditionals/exercises/part-1.js @@ -1,6 +1,16 @@ // Declare and initialize the variables for exercise 1 here: // BEFORE running the code, predict what will be printed to the console by the following statements: +let engineIndicatorLight = "NOT red blinking"; +let spaceSuitsOn = true; +let shuttleCabinReady = true; +let crewStatus = spaceSuitsOn && shuttleCabinReady; +let computerStatusCode = 200; +let shuttleSpeed = 21000; +let fuelLevel = 900; +let engineTemperature = 2400; +let commandOverride = false; + if (engineIndicatorLight === "green") { console.log("engines have started"); @@ -9,3 +19,45 @@ if (engineIndicatorLight === "green") { } else { console.log("engines are off"); } + +if (crewStatus === true) { + console.log("Crew Ready"); +} else { + console.log("Crew Not Ready"); +} + +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!"); +} + +if (shuttleSpeed > 17500) { + console.log("ALERT: Escape velocity reached!"); +} else if (shuttleSpeed < 8000) { + console.log("ALERT: Cannot maintain orbit!"); +} else { + console.log("Stable speed"); +} + +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..."); +} + +if (fuelLevel > 20000 && engineIndicatorLight === "NOT 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/exercises/part-2.js b/booleans-and-conditionals/exercises/part-2.js index ff11fbab8a..ef381c4561 100644 --- a/booleans-and-conditionals/exercises/part-2.js +++ b/booleans-and-conditionals/exercises/part-2.js @@ -1,9 +1,65 @@ -let engineIndicatorLight = "red blinking"; +let engineIndicatorLight = "NOT red blinking"; let spaceSuitsOn = true; let shuttleCabinReady = true; let crewStatus = spaceSuitsOn && shuttleCabinReady; let computerStatusCode = 200; -let shuttleSpeed = 15000; +let shuttleSpeed = 21000; +let fuelLevel = 900; +let engineTemperature = 2400; +let commandOverride = false; + + +if (engineIndicatorLight === "green") { + console.log("engines have started"); +} else if (engineIndicatorLight === "green blinking") { + console.log("engines are preparing to start"); +} else { + console.log("engines are off"); +} + +if (crewStatus === true) { + console.log("Crew Ready"); +} else { + console.log("Crew Not Ready"); +} + +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!"); +} + +if (shuttleSpeed > 17500) { + console.log("ALERT: Escape velocity reached!"); +} else if (shuttleSpeed < 8000) { + console.log("ALERT: Cannot maintain orbit!"); +} else { + console.log("Stable speed"); +} + +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..."); +} + +if (fuelLevel > 20000 && engineIndicatorLight === "NOT red blinking" || commandOverride === true) { + console.log("Cleared to launch!"); +} else { + console.log("Launch scrubbed!"); +} + +console.log("Yes"); // 3) Write conditional expressions to satisfy the following safety rules: @@ -18,4 +74,4 @@ let shuttleSpeed = 15000; // 4) PREDICT: Do the code blocks shown in the 'predict.txt' file produce the same result? -console.log(/* "Yes" or "No" */); + diff --git a/booleans-and-conditionals/exercises/part-3.js b/booleans-and-conditionals/exercises/part-3.js index 9ed686d097..97bfb03902 100644 --- a/booleans-and-conditionals/exercises/part-3.js +++ b/booleans-and-conditionals/exercises/part-3.js @@ -1,6 +1,64 @@ -let engineIndicatorLight = 'red blinking'; -let fuelLevel = 21000; -let engineTemperature = 1200; + +let engineIndicatorLight = "NOT red blinking"; +let spaceSuitsOn = true; +let shuttleCabinReady = true; +let crewStatus = spaceSuitsOn && shuttleCabinReady; +let computerStatusCode = 200; +let shuttleSpeed = 21000; +let fuelLevel = 900; +let engineTemperature = 2400; +let commandOverride = false; + + +if (engineIndicatorLight === "green") { + console.log("engines have started"); +} else if (engineIndicatorLight === "green blinking") { + console.log("engines are preparing to start"); +} else { + console.log("engines are off"); +} + +if (crewStatus === true) { + console.log("Crew Ready"); +} else { + console.log("Crew Not Ready"); +} + +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!"); +} + +if (shuttleSpeed > 17500) { + console.log("ALERT: Escape velocity reached!"); +} else if (shuttleSpeed < 8000) { + console.log("ALERT: Cannot maintain orbit!"); +} else { + console.log("Stable speed"); +} + +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..."); +} + +if (fuelLevel > 20000 && engineIndicatorLight === "NOT red blinking" || commandOverride === true) { + console.log("Cleared to launch!"); +} else { + console.log("Launch scrubbed!"); +} /* 5) Implement the following checks using if/else if/else statements: diff --git a/booleans-and-conditionals/studio/data-variables-conditionals.js b/booleans-and-conditionals/studio/data-variables-conditionals.js index 6a15e146f4..06b272f29f 100644 --- a/booleans-and-conditionals/studio/data-variables-conditionals.js +++ b/booleans-and-conditionals/studio/data-variables-conditionals.js @@ -13,3 +13,37 @@ // add logic below to verify the weather status is clear // Verify shuttle launch can proceed based on above conditions +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 fuelTempCelcius = -225; +let minimumFuelTemp = -300; +let maximumFuelTemp = -150; +let fuelLevel = "100%"; +let weatherStatus = "Clear"; +let preparedForLiftOff = true; + +if (astronautCount <= 7 && astronautStatus === "Ready" && totalMassKG < maximumMassLimit && fuelTempCelcius > minimumFuelTemp && fuelTempCelcius < maximumFuelTemp && fuelLevel === "100%" && weatherStatus === "Clear"){ + preparedForLiftOff === true; + console.log("Launch conditions achieved. All systems go."); + console.log("Date: ", date); + console.log("Time: ", time); + console.log("Astronaut Count: ", astronautCount); + console.log("Crew Mass KG: ", crewMassKG); + console.log("Fuel Mass KG: ", fuelMassKg); + console.log("Shuttle Mass KG: ", shuttleMassKg); + console.log("Total Mass KG: ", totalMassKG); + console.log("Fuel Temp (C): ", fuelTempCelcius); + console.log("Weather Status: ", weatherStatus); + console.log("Godspeed, Astronauts!"); +} else { + console.log("ERROR: Launch conditions not met. Launch Scrubbed"); +} + diff --git a/classes/exercises/ClassExercises.js b/classes/exercises/ClassExercises.js index 91b9ee5b9d..b0cfde17c6 100644 --- a/classes/exercises/ClassExercises.js +++ b/classes/exercises/ClassExercises.js @@ -1,10 +1,52 @@ // Define your Book class here: - - -// Define your Manual and Novel classes here: - +class Book { + constructor(title, author, copyright, isbn, pages, timesCheckedOut, discarded){ + this.title = title; + this.author = author; + this.copyright = copyright; + this.isbn = isbn; + this.pages = pages; + this.timesCheckedOut = timesCheckedOut; + this.discarded = discarded; + } + + checkout(uses=1) { + this.timesCheckedOut += uses; + } + } + + class Manual extends Book { + constructor(title, author, copyright, isbn, pages, timesCheckedOut, discarded){ + super(title, author, copyright, isbn, pages, timesCheckedOut, discarded); + } + + dispose(currentYear){ + if (currentYear-this.copyright > 5) { + this.discarded = 'Yes'; + } + return this.discarded; + } + } + + class Novel extends Book { + constructor(title, author, copyright, isbn, pages, timesCheckedOut, discarded){ + super(title, author, copyright, isbn, pages, timesCheckedOut, discarded); + } + + dispose(){ + if (this.timesCheckedOut > 100) { + this.discarded = 'Yes'; + } + return this.discarded; + } + } // Declare the objects for exercises 2 and 3 here: +let prideAndPrejudice = new Novel('Pride and Prejudice', 'Jane Austen', 1813, 1111111111111, 432, 32, 'No'); +let makingTheShip = new Manual('Top Secret Shuttle Building Manual', 'Redacted', 2013, '0000000000000', 1147, 1, 'No'); +// Code exercises 4 & 5 here: -// Code exercises 4 & 5 here: \ No newline at end of file +console.log(makingTheShip.dispose(2024)); +prideAndPrejudice.checkout(5); +console.log(prideAndPrejudice); \ No newline at end of file diff --git a/classes/studio/ClassStudio.js b/classes/studio/ClassStudio.js index c3a6152140..d214faee5e 100644 --- a/classes/studio/ClassStudio.js +++ b/classes/studio/ClassStudio.js @@ -1,9 +1,51 @@ //Declare a class called CrewCandidate with a constructor that takes three parameters—name, mass, and scores. Note that scores will be an array of test results. +class CrewCandidate { + constructor(name, mass, scores){ + this.name = name; + this.mass = mass; + this.scores = scores; + } + addScore(newScore){ + this.scores.push(newScore); + } + average(){ + let sum = 0; + for (let i = 0; i < this.scores.length; i++){ + sum += this.scores[i]; + } + return sum / this.scores.length; + } + + status(){ + let average = this.average(); + if (average >= 90){ + return "Accepted"; + } else if (average < 90 && average >= 80){ + return "Reserve"; + } else if (average < 80 && average >= 70){ + return "Probationary"; + } return "Rejected"; + + } + +} + + let bubbaBear = new CrewCandidate('Bubba Bear', 135, [88, 85, 90]); + let merryMaltese = new CrewCandidate('Merry Maltese', 1.5, [93, 88, 97]); + let gladGator = new CrewCandidate('Glad Gator', 225, [75, 78, 62]); + + console.log(bubbaBear); + console.log(merryMaltese); + console.log(gladGator); //Add methods for adding scores, averaging scores and determining candidate status as described in the studio activity. +bubbaBear.addScore(83); +console.log(bubbaBear); +console.log(merryMaltese.average()); +console.log(`${bubbaBear.name} earned an average test score of ${bubbaBear.average()} % and has a status of ${bubbaBear.status()}!`); //Part 4 - Use the methods to boost Glad Gator’s status to Reserve or higher. How many tests will it take to reach Reserve status? How many to reach Accepted? Remember, scores cannot exceed 100%. \ No newline at end of file diff --git a/css/exercises/index.html b/css/exercises/index.html index 922e8e3885..b80dffa148 100644 --- a/css/exercises/index.html +++ b/css/exercises/index.html @@ -9,13 +9,13 @@
-Web Development is a very cool skill that I love learning!
I love making websites because all I have to do is reload the page to see the changes I have made!
diff --git a/css/exercises/styles.css b/css/exercises/styles.css index 3b88bed453..b754eb2c39 100644 --- a/css/exercises/styles.css +++ b/css/exercises/styles.css @@ -1 +1,23 @@ /* Start adding your styling below! */ +body { + background-color: yellow; +} +p { + color: green; +} + +h1 { + font-size: 36px; +} + +.centeredHeadings { + text-align: center; +} + +#cool-text{ + color: blue; +} + +#niceList { + color: red; +} \ No newline at end of file diff --git a/data-and-variables/exercises/data-and-variables-exercises.js b/data-and-variables/exercises/data-and-variables-exercises.js index 6433bcd641..e7c49e6cbf 100644 --- a/data-and-variables/exercises/data-and-variables-exercises.js +++ b/data-and-variables/exercises/data-and-variables-exercises.js @@ -1,11 +1,25 @@ -// Declare and assign the variables below +let shuttleName = "Determination"; +let shuttleSpeedMph = 17500; +let distance2MarsKm = 225000000; +let distance2MoonKm = 384400; +let 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 distance2Markskm); +console.log(typeof distance2MoonKm); +console.log(typeof milesPerKm); -// Calculate a space mission below +let miles2Mars = distance2MarsKm * milesPerKm; +let hours2Mars = miles2Mars/shuttleSpeedMph; +let days2Mars = hours2Mars/24; +console.log(miles2Mars); +console.log(hours2Mars); +console.log(days2Mars); +console.log(shuttleName + " will take " + days2Mars + " days to reach Mars."); -// Print the results of the space mission calculations below +let miles2Moon = distance2MoonKm * milesPerKm; +let hours2Moon = miles2Moon / shuttleSpeedMph; +let days2Moon = hours2Moon / 24; -// Calculate a trip to the moon below - -// Print the results of the trip to the moon below \ No newline at end of file +console.log(shuttleName + " will take " + days2Moon + " 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..640ca28feb 100644 --- a/dom-and-events/exercises/script.js +++ b/dom-and-events/exercises/script.js @@ -3,8 +3,29 @@ function init () { const button = document.getElementById("liftoffButton"); const paragraph = document.getElementById("statusReport"); - // Put your code for the exercises here. + button.addEventListener("click", function() { + document.getElementById("statusReport").innerHTML = "Houston, we have liftoff!"; + }) + + missionAbort.addEventListener("mouseover", function() { + missionAbort.style.backgroundColor = "red"; + }) + + missionAbort.addEventListener("mouseout", function() { + missionAbort.style.backgroundColor = ""; + }) + + missionAbort.addEventListener("click", function() { + let response = window.confirm("Are you sure you want to abort the mission?"); + if (response) { + paragraph.innerHTML = "Mission aborted! Space shuttle returning home"; + } + }) + + + + } window.addEventListener("load", init); 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..6926cb279a 100644 --- a/errors-and-debugging/exercises/DebuggingLogicErrors2.js +++ b/errors-and-debugging/exercises/DebuggingLogicErrors2.js @@ -15,7 +15,9 @@ if (fuelLevel >= 20000) { } else { 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..1263c8f995 100644 --- a/errors-and-debugging/exercises/DebuggingLogicErrors3.js +++ b/errors-and-debugging/exercises/DebuggingLogicErrors3.js @@ -26,6 +26,8 @@ if (crewStatus && computerStatus === 'green'){ 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..d43828bfec 100644 --- a/errors-and-debugging/exercises/DebuggingLogicErrors5.js +++ b/errors-and-debugging/exercises/DebuggingLogicErrors5.js @@ -3,9 +3,11 @@ // Refactor the code to do this. Verify that your change works by updating the console.log statements. let launchReady = false; -let fuelLevel = 17000; +let fuelLevel = 21000; let crewStatus = true; let computerStatus = 'green'; +let crewReady = false; + if (fuelLevel >= 20000) { console.log('Fuel level cleared.'); @@ -14,15 +16,19 @@ if (fuelLevel >= 20000) { console.log('WARNING: Insufficient fuel!'); launchReady = false; } - console.log("launchReady = ", launchReady); - +n 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("crewReady = ", crewReady); -console.log("launchReady = ", launchReady); \ No newline at end of file +if (crewReady === true && launchReady === true) { + console.log("3... 2... 1... Liftoff!"); +} 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..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!"); diff --git a/exceptions/exercises/divide.js b/exceptions/exercises/divide.js index 06fc889862..1c81918438 100644 --- a/exceptions/exercises/divide.js +++ b/exceptions/exercises/divide.js @@ -5,3 +5,14 @@ // However, if the denominator is zero you should throw the error, "Attempted to divide by zero." // Code your divide function here: + + +function divide(numerator, denominator) { + if (denominator === 0) { + throw Error('You cannot divide by zero!'); + } + return numerator/denominator; + }; + + console.log(divide(2,1)); + console.log(divide(4, 0)); \ No newline at end of file diff --git a/exceptions/exercises/test-student-labs.js b/exceptions/exercises/test-student-labs.js index cfe5bfe175..16b443a1b5 100644 --- a/exceptions/exercises/test-student-labs.js +++ b/exceptions/exercises/test-student-labs.js @@ -1,10 +1,14 @@ function gradeLabs(labs) { - for (let i=0; i < labs.length; i++) { + try { + for (let i=0; i < labs.length; i++) { let lab = labs[i]; let result = lab.runLab(3); console.log(`${lab.student} code worked: ${result === 27}`); + } + } catch(err) { + console.log("Error! You did it all wrong, goofball. A runLab function is undefined."); + } } -} let studentLabs = [ { @@ -22,3 +26,27 @@ let studentLabs = [ ]; gradeLabs(studentLabs); + + +let studentLabs2 = [ + { + student: 'Blake', + myCode: function (num) { + return Math.pow(num, num); + } + }, + { + student: 'Jessica', + runLab: function (num) { + return Math.pow(num, num); + } + }, + { + student: 'Mya', + runLab: function (num) { + return num * num; + } + } +]; + +gradeLabs(studentLabs2); diff --git a/fetch/fetch_planets.html b/fetch/fetch_planets.html new file mode 100644 index 0000000000..480cd0d0da --- /dev/null +++ b/fetch/fetch_planets.html @@ -0,0 +1,33 @@ + + + +I'm dreaming up a very simple website about literature and/or poetry. I love the aesthetic of command line interfaces and old, simple web pages from the '90s. My website will channel some of this for a simple, clean experience of poems and other writing.