From 2845d9e05f598d7f5307f353f253a506081b0e5d Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Thu, 27 Jul 2023 14:48:23 -0500 Subject: [PATCH 01/46] booleans and conditionals exercises starter-code --- booleans-and-conditionals/part-1.js | 11 +++++++++++ booleans-and-conditionals/part-2.js | 21 +++++++++++++++++++++ booleans-and-conditionals/part-3.js | 24 ++++++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 booleans-and-conditionals/part-1.js create mode 100644 booleans-and-conditionals/part-2.js create mode 100644 booleans-and-conditionals/part-3.js diff --git a/booleans-and-conditionals/part-1.js b/booleans-and-conditionals/part-1.js new file mode 100644 index 0000000000..b829140a07 --- /dev/null +++ b/booleans-and-conditionals/part-1.js @@ -0,0 +1,11 @@ +// 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: + +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"); +} diff --git a/booleans-and-conditionals/part-2.js b/booleans-and-conditionals/part-2.js new file mode 100644 index 0000000000..ff11fbab8a --- /dev/null +++ b/booleans-and-conditionals/part-2.js @@ -0,0 +1,21 @@ +let engineIndicatorLight = "red blinking"; +let spaceSuitsOn = true; +let shuttleCabinReady = true; +let crewStatus = spaceSuitsOn && shuttleCabinReady; +let computerStatusCode = 200; +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". + + +// 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!" + + +// 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". + + +// 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/part-3.js b/booleans-and-conditionals/part-3.js new file mode 100644 index 0000000000..9ed686d097 --- /dev/null +++ b/booleans-and-conditionals/part-3.js @@ -0,0 +1,24 @@ +let engineIndicatorLight = 'red blinking'; +let fuelLevel = 21000; +let engineTemperature = 1200; + +/* 5) Implement the following checks using if/else if/else statements: + +a) If fuelLevel is above 20000 AND engineTemperature is at or below 2500, print "Full tank. Engines good." + +b) If fuelLevel is above 10000 AND engineTemperature is at or below 2500, print "Fuel level above 50%. Engines good." + +c) If fuelLevel is above 5000 AND engineTemperature is at or below 2500, print "Fuel level above 25%. Engines good." + +d) If fuelLevel is at or below 5000 OR engineTemperature is above 2500, print "Check fuel level. Engines running hot." + +e) If fuelLevel is below 1000 OR engineTemperature is above 3500 OR engineIndicatorLight is red blinking print "ENGINE FAILURE IMMINENT!" + +f) Otherwise, print "Fuel and engine status pending..." */ + +// Code 5a - 5f here: + +// 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!" */ From 48c80a0466dd2af3868e22b7d2ed62817f2548d4 Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Thu, 27 Jul 2023 16:59:09 -0500 Subject: [PATCH 02/46] starter code for exercises and studio chapter 5 --- .../{ => exercises}/part-1.js | 0 .../{ => exercises}/part-2.js | 0 .../{ => exercises}/part-3.js | 0 .../studio/data-variables-conditionals.js | 15 +++++++++++++++ 4 files changed, 15 insertions(+) rename booleans-and-conditionals/{ => exercises}/part-1.js (100%) rename booleans-and-conditionals/{ => exercises}/part-2.js (100%) rename booleans-and-conditionals/{ => exercises}/part-3.js (100%) create mode 100644 booleans-and-conditionals/studio/data-variables-conditionals.js diff --git a/booleans-and-conditionals/part-1.js b/booleans-and-conditionals/exercises/part-1.js similarity index 100% rename from booleans-and-conditionals/part-1.js rename to booleans-and-conditionals/exercises/part-1.js diff --git a/booleans-and-conditionals/part-2.js b/booleans-and-conditionals/exercises/part-2.js similarity index 100% rename from booleans-and-conditionals/part-2.js rename to booleans-and-conditionals/exercises/part-2.js diff --git a/booleans-and-conditionals/part-3.js b/booleans-and-conditionals/exercises/part-3.js similarity index 100% rename from booleans-and-conditionals/part-3.js rename to booleans-and-conditionals/exercises/part-3.js diff --git a/booleans-and-conditionals/studio/data-variables-conditionals.js b/booleans-and-conditionals/studio/data-variables-conditionals.js new file mode 100644 index 0000000000..65ddac9e9a --- /dev/null +++ b/booleans-and-conditionals/studio/data-variables-conditionals.js @@ -0,0 +1,15 @@ +// Initialize Variables below + +// add logic below to determine the amount of astronauts on the shuttle + +// add logic below to check if astronauts are ready + +// add logic below to check if the total mass is less than the maximum limit + +// add logic below to check if the fuel temp is no less than 200 OR no greater than 300 + +// add logic below to determine if fuel level is appropriate + +// add logic below to check if weather conditions are appropriate + +// Based on the above conditions, verify that the shuttle is ready for LiftOff From db4a00655a81b181c1b4e51d35cc174da13c0989 Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Fri, 28 Jul 2023 09:45:22 -0500 Subject: [PATCH 03/46] updates to comments --- .../studio/data-variables-conditionals.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/booleans-and-conditionals/studio/data-variables-conditionals.js b/booleans-and-conditionals/studio/data-variables-conditionals.js index 65ddac9e9a..6a15e146f4 100644 --- a/booleans-and-conditionals/studio/data-variables-conditionals.js +++ b/booleans-and-conditionals/studio/data-variables-conditionals.js @@ -1,15 +1,15 @@ // Initialize Variables below -// add logic below to determine the amount of astronauts on the shuttle +// add logic below to verify total number of astronauts for shuttle launch does not exceed 7 -// add logic below to check if astronauts are ready +// add logic below to verify all astronauts are ready -// add logic below to check if the total mass is less than the maximum limit +// add logic below to verify the total mass does not exceed the maximum limit of 850000 -// add logic below to check if the fuel temp is no less than 200 OR no greater than 300 +// add logic below to verify the fuel temperature is within the appropriate range of -150 and -300 -// add logic below to determine if fuel level is appropriate +// add logic below to verify the fuel level is at 100% -// add logic below to check if weather conditions are appropriate +// add logic below to verify the weather status is clear -// Based on the above conditions, verify that the shuttle is ready for LiftOff +// Verify shuttle launch can proceed based on above conditions From 2b346b80812dc2dad55e798a0b68eb2d9ec09642 Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Wed, 2 Aug 2023 09:54:28 -0500 Subject: [PATCH 04/46] added starter code for exercises and legacy repl.it code --- .../code-snippets/bracket-notation.js | 4 +++ .../code-snippets/mad-libs.js | 7 ++++ .../code-snippets/method-chaining.js | 11 +++++++ .../exercises/part-one.js | 10 ++++++ .../exercises/part-three.js | 17 ++++++++++ .../exercises/part-two.js | 32 +++++++++++++++++++ 6 files changed, 81 insertions(+) create mode 100644 stringing-characters-together/code-snippets/bracket-notation.js create mode 100644 stringing-characters-together/code-snippets/mad-libs.js create mode 100644 stringing-characters-together/code-snippets/method-chaining.js create mode 100644 stringing-characters-together/exercises/part-one.js create mode 100644 stringing-characters-together/exercises/part-three.js create mode 100644 stringing-characters-together/exercises/part-two.js diff --git a/stringing-characters-together/code-snippets/bracket-notation.js b/stringing-characters-together/code-snippets/bracket-notation.js new file mode 100644 index 0000000000..5b07c358ad --- /dev/null +++ b/stringing-characters-together/code-snippets/bracket-notation.js @@ -0,0 +1,4 @@ +let jsCreator = "Brendan Eich"; + +console.log(jsCreator[-1]); +console.log(jsCreator[42]); diff --git a/stringing-characters-together/code-snippets/mad-libs.js b/stringing-characters-together/code-snippets/mad-libs.js new file mode 100644 index 0000000000..7d665985d2 --- /dev/null +++ b/stringing-characters-together/code-snippets/mad-libs.js @@ -0,0 +1,7 @@ +let pluralNoun = ; +let name = ; +let verb = ; +let adjective = ; +let color = ; + +console.log("JavaScript provides a "+ color +" collection of tools — including " + adjective + " syntax and " + pluralNoun + " — that allows "+ name +" to "+ verb +" with strings.") diff --git a/stringing-characters-together/code-snippets/method-chaining.js b/stringing-characters-together/code-snippets/method-chaining.js new file mode 100644 index 0000000000..43fcd55bc7 --- /dev/null +++ b/stringing-characters-together/code-snippets/method-chaining.js @@ -0,0 +1,11 @@ +//String methods can be combined in a process called method chaining. + +let word = 'JavaScript'; + +console.log(word.toUpperCase()); +//Returns ``JAVASCRIPT`` + +//What does ``word.slice(4).toUpperCase()`` return? + + +//Experiment with other combinations (chains) of string methods. diff --git a/stringing-characters-together/exercises/part-one.js b/stringing-characters-together/exercises/part-one.js new file mode 100644 index 0000000000..9295e4dd9f --- /dev/null +++ b/stringing-characters-together/exercises/part-one.js @@ -0,0 +1,10 @@ +let num = 1001; + +//Returns 'undefined'. +console.log(num.length); + +//Use type conversion to print the length (number of digits) of an integer. + +//Follow up: Print the number of digits in a DECIMAL value (e.g. num = 123.45 has 5 digits but a length of 6). + +//Experiment! What if num could be EITHER an integer or a decimal? Add an if/else statement so your code can handle both cases. diff --git a/stringing-characters-together/exercises/part-three.js b/stringing-characters-together/exercises/part-three.js new file mode 100644 index 0000000000..8c310f1445 --- /dev/null +++ b/stringing-characters-together/exercises/part-three.js @@ -0,0 +1,17 @@ +//Part Three section one + +let language = 'JavaScript'; + +//1. Use string concatenation and two slice() methods to print 'JS' from 'JavaScript' + +//2. Without using slice(), use method chaining to accomplish the same thing. + +//3. Use bracket notation and a template literal to print, "The abbreviation for 'JavaScript' is 'JS'." + +//4. Just for fun, try chaining 3 or more methods together, and then print the result. + +//Part Three section Two + +//1. Use the string methods you know to print 'Title Case' from the string 'title case'. + +let notTitleCase = 'title case'; diff --git a/stringing-characters-together/exercises/part-two.js b/stringing-characters-together/exercises/part-two.js new file mode 100644 index 0000000000..a06e9094dc --- /dev/null +++ b/stringing-characters-together/exercises/part-two.js @@ -0,0 +1,32 @@ +//Part Two Section One + +let dna = " TCG-TAC-gaC-TAC-CGT-CAG-ACT-TAa-CcA-GTC-cAt-AGA-GCT "; + +// First, print out the dna strand in it's current state. + +//1) Use the .trim() method to remove the leading and trailing whitespace, then print the result. + +console.log(/* Your code here. */); + +//2) Change all of the letters in the dna string to UPPERCASE, then print the result. + +console.log(); + +//3) Note that after applying the methods above, the original, flawed string is still stored in dna. To fix this, we need to reassign the changes to back to dna. +//Apply these fixes to your code so that console.log(dna) prints the DNA strand in UPPERCASE with no whitespace. + +console.log(dna); + +//Part Two Section Two + +let dnaTwo = "TCG-TAC-GAC-TAC-CGT-CAG-ACT-TAA-CCA-GTC-CAT-AGA-GCT"; + +//1) Replace the gene "GCT" with "AGG", and then print the altered strand. + +//2) Look for the gene "CAT" with ``indexOf()``. If found print, "CAT gene found", otherwise print, "CAT gene NOT found". + +//3) Use .slice() to print out the fifth gene (set of 3 characters) from the DNA strand. + +//4) Use a template literal to print, "The DNA strand is ___ characters long." + +//5) Just for fun, apply methods to ``dna`` and use another template literal to print, 'taco cat'. From 08500cc64d858846c3998901c115dc30aae6baac Mon Sep 17 00:00:00 2001 From: Sally Steuterman Date: Wed, 2 Aug 2023 16:47:22 -0500 Subject: [PATCH 05/46] Updating starter code for errors and debugging --- .../chapter-examples/Syntax-Highlighting.js | 2 + .../chapter-examples/SyntaxErrors.js | 2 + .../exercises/Debugging1stSyntaxError.js | 13 +++++++ .../exercises/DebuggingLogicErrors1.js | 32 ++++++++++++++++ .../exercises/DebuggingLogicErrors2.js | 33 +++++++++++++++++ .../exercises/DebuggingLogicErrors3.js | 34 +++++++++++++++++ .../exercises/DebuggingLogicErrors4.js | 37 +++++++++++++++++++ .../exercises/DebuggingLogicErrors5.js | 28 ++++++++++++++ .../exercises/DebuggingRuntimeErrors1.js | 13 +++++++ .../exercises/DebuggingRuntimeErrors2.js | 0 .../exercises/DebuggingSyntaxErrors2.js | 26 +++++++++++++ 11 files changed, 220 insertions(+) create mode 100644 errors-and-debugging/chapter-examples/Syntax-Highlighting.js create mode 100644 errors-and-debugging/chapter-examples/SyntaxErrors.js create mode 100644 errors-and-debugging/exercises/Debugging1stSyntaxError.js create mode 100644 errors-and-debugging/exercises/DebuggingLogicErrors1.js create mode 100644 errors-and-debugging/exercises/DebuggingLogicErrors2.js create mode 100644 errors-and-debugging/exercises/DebuggingLogicErrors3.js create mode 100644 errors-and-debugging/exercises/DebuggingLogicErrors4.js create mode 100644 errors-and-debugging/exercises/DebuggingLogicErrors5.js create mode 100644 errors-and-debugging/exercises/DebuggingRuntimeErrors1.js create mode 100644 errors-and-debugging/exercises/DebuggingRuntimeErrors2.js create mode 100644 errors-and-debugging/exercises/DebuggingSyntaxErrors2.js diff --git a/errors-and-debugging/chapter-examples/Syntax-Highlighting.js b/errors-and-debugging/chapter-examples/Syntax-Highlighting.js new file mode 100644 index 0000000000..8550a709e1 --- /dev/null +++ b/errors-and-debugging/chapter-examples/Syntax-Highlighting.js @@ -0,0 +1,2 @@ +let name = Julie; +console.log("Hello, name); \ No newline at end of file diff --git a/errors-and-debugging/chapter-examples/SyntaxErrors.js b/errors-and-debugging/chapter-examples/SyntaxErrors.js new file mode 100644 index 0000000000..5597f22de5 --- /dev/null +++ b/errors-and-debugging/chapter-examples/SyntaxErrors.js @@ -0,0 +1,2 @@ +let day = Wednesday; +console.log(day; \ No newline at end of file diff --git a/errors-and-debugging/exercises/Debugging1stSyntaxError.js b/errors-and-debugging/exercises/Debugging1stSyntaxError.js new file mode 100644 index 0000000000..365af5a964 --- /dev/null +++ b/errors-and-debugging/exercises/Debugging1stSyntaxError.js @@ -0,0 +1,13 @@ +//Run this code first and examine the error message. +//Fix the syntax error then run the code again to check your work. + +let launchReady = false; +let fuelLevel = 17000; + +if (fuelLevel >= 20000 { + console.log('Fuel level cleared.'); + launchReady = true; +} else { + console.log('WARNING: Insufficient fuel!'); + launchReady = false; +} \ No newline at end of file diff --git a/errors-and-debugging/exercises/DebuggingLogicErrors1.js b/errors-and-debugging/exercises/DebuggingLogicErrors1.js new file mode 100644 index 0000000000..1ad473f08d --- /dev/null +++ b/errors-and-debugging/exercises/DebuggingLogicErrors1.js @@ -0,0 +1,32 @@ +// Run this sample code as-is and examine the output. +// Should the shuttle have launched? +// Did it? +// Do not worry about fixing the code yet, we will do that in the next series of exercises. + +let launchReady = false; +let fuelLevel = 17000; +let crewStatus = true; +let computerStatus = 'green'; + +if (fuelLevel >= 20000) { + console.log('Fuel level cleared.'); + launchReady = true; +} else { + console.log('WARNING: Insufficient fuel!'); + launchReady = false; +} + +if (crewStatus && computerStatus === 'green'){ + console.log('Crew & computer cleared.'); + launchReady = true; +} else { + console.log('WARNING: Crew or computer not ready!'); + launchReady = false; +} + +if (launchReady) { + console.log('10, 9, 8, 7, 6, 5, 4, 3, 2, 1...'); + console.log('Liftoff!'); +} else { + console.log('Launch scrubbed.'); +} \ No newline at end of file diff --git a/errors-and-debugging/exercises/DebuggingLogicErrors2.js b/errors-and-debugging/exercises/DebuggingLogicErrors2.js new file mode 100644 index 0000000000..160a0c2cd0 --- /dev/null +++ b/errors-and-debugging/exercises/DebuggingLogicErrors2.js @@ -0,0 +1,33 @@ +// Let’s break the code down into smaller chunks. +// Consider the first if/else block below. +// Add console.log(launchReady) after this block, then run the program. + +//Given the fuelLevel value, should launchReady be true or false after the check? Is the program behaving as expected? + +let launchReady = false; +let fuelLevel = 17000; +// let crewStatus = true; +// let computerStatus = 'green'; + +if (fuelLevel >= 20000) { + console.log('Fuel level cleared.'); + launchReady = true; +} else { + console.log('WARNING: Insufficient fuel!'); + launchReady = false; +} + +// if (crewStatus && computerStatus === 'green'){ +// console.log('Crew & computer cleared.'); +// launchReady = true; +// } else { +// console.log('WARNING: Crew or computer not ready!'); +// launchReady = false; +// } + +// if (launchReady) { +// console.log('10, 9, 8, 7, 6, 5, 4, 3, 2, 1...'); +// console.log('Liftoff!'); +// } else { +// console.log('Launch scrubbed.'); +// } \ No newline at end of file diff --git a/errors-and-debugging/exercises/DebuggingLogicErrors3.js b/errors-and-debugging/exercises/DebuggingLogicErrors3.js new file mode 100644 index 0000000000..023f2ab07d --- /dev/null +++ b/errors-and-debugging/exercises/DebuggingLogicErrors3.js @@ -0,0 +1,34 @@ +// Let’s break the code down into smaller chunks. +// Now consider the second if/else block. +// Add another console.log(launchReady) after this block and run the program. + +// Given the values for crewStatus and computerStatus, should launchReady be true or false after the check? +// Is the program behaving as expected? + +let launchReady = false; +// let fuelLevel = 17000; +let crewStatus = true; +let computerStatus = 'green'; + +// if (fuelLevel >= 20000) { +// console.log('Fuel level cleared.'); +// launchReady = true; +// } else { +// console.log('WARNING: Insufficient fuel!'); +// launchReady = false; +// } + +if (crewStatus && computerStatus === 'green'){ + console.log('Crew & computer cleared.'); + launchReady = true; +} else { + console.log('WARNING: Crew or computer not ready!'); + launchReady = false; +} + +// if (launchReady) { +// console.log('10, 9, 8, 7, 6, 5, 4, 3, 2, 1...'); +// console.log('Liftoff!'); +// } else { +// console.log('Launch scrubbed.'); +// } \ No newline at end of file diff --git a/errors-and-debugging/exercises/DebuggingLogicErrors4.js b/errors-and-debugging/exercises/DebuggingLogicErrors4.js new file mode 100644 index 0000000000..dc9ac0af9d --- /dev/null +++ b/errors-and-debugging/exercises/DebuggingLogicErrors4.js @@ -0,0 +1,37 @@ +// Now consider both if/else blocks together (keeping the added console.log lines). +// Run the code and examine the output. + +// Given the values for fuelLevel, crewStatus and computerStatus, should launchReady be true or false? +// Is the program behaving as expected? + +let launchReady = false; +let fuelLevel = 17000; +let crewStatus = true; +let computerStatus = 'green'; + +if (fuelLevel >= 20000) { + console.log('Fuel level cleared.'); + launchReady = true; +} else { + console.log('WARNING: Insufficient fuel!'); + launchReady = false; +} + +console.log("launchReady = ", launchReady); + +if (crewStatus && computerStatus === 'green'){ + console.log('Crew & computer cleared.'); + launchReady = true; +} else { + console.log('WARNING: Crew or computer not ready!'); + launchReady = false; +} + +console.log("launchReady = ", launchReady); + +// if (launchReady) { +// console.log('10, 9, 8, 7, 6, 5, 4, 3, 2, 1...'); +// console.log('Liftoff!'); +// } else { +// console.log('Launch scrubbed.'); +// } \ No newline at end of file diff --git a/errors-and-debugging/exercises/DebuggingLogicErrors5.js b/errors-and-debugging/exercises/DebuggingLogicErrors5.js new file mode 100644 index 0000000000..7eb908e769 --- /dev/null +++ b/errors-and-debugging/exercises/DebuggingLogicErrors5.js @@ -0,0 +1,28 @@ +// The value of launchReady assigned in the first if/else block gets changed in the second if/else block. Dangerous waters... +// Since the issue is with launchReady, ONE way to fix the logic error is to use a different variable to store the fuel check result. +// Refactor the code to do this. Verify that your change works by updating the console.log statements. + +let launchReady = false; +let fuelLevel = 17000; +let crewStatus = true; +let computerStatus = 'green'; + +if (fuelLevel >= 20000) { + console.log('Fuel level cleared.'); + launchReady = true; +} else { + console.log('WARNING: Insufficient fuel!'); + launchReady = false; +} + +console.log("launchReady = ", launchReady); + +if (crewStatus && computerStatus === 'green'){ + console.log('Crew & computer cleared.'); + launchReady = true; +} else { + console.log('WARNING: Crew or computer not ready!'); + launchReady = false; +} + +console.log("launchReady = ", launchReady); \ No newline at end of file diff --git a/errors-and-debugging/exercises/DebuggingRuntimeErrors1.js b/errors-and-debugging/exercises/DebuggingRuntimeErrors1.js new file mode 100644 index 0000000000..e66e494a30 --- /dev/null +++ b/errors-and-debugging/exercises/DebuggingRuntimeErrors1.js @@ -0,0 +1,13 @@ +//Run this code first and examine the error message. +//Pay close attention to any line numbers mentioned in the message - these will help locate and repair the mistake in the code. + +let launchReady = false; +let fuelLevel = 17000; + +if (fuellevel >= 20000) { + console.log('Fuel level cleared.'); + launchReady = true; +} else { + console.log('WARNING: Insufficient fuel!'); + launchReady = false; +} \ No newline at end of file diff --git a/errors-and-debugging/exercises/DebuggingRuntimeErrors2.js b/errors-and-debugging/exercises/DebuggingRuntimeErrors2.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/errors-and-debugging/exercises/DebuggingSyntaxErrors2.js b/errors-and-debugging/exercises/DebuggingSyntaxErrors2.js new file mode 100644 index 0000000000..b600339254 --- /dev/null +++ b/errors-and-debugging/exercises/DebuggingSyntaxErrors2.js @@ -0,0 +1,26 @@ +//This block of code hides two syntax errors. + +// Run the code and find the mistakes. +// Only ONE error will be flagged at a time. +// Fix that ONE problem, and then re-run the code to check yer work. Avoid trying to fix multiple issues at once. + +let launchReady = false; +let crewStatus = true; +let computerStatus = 'green'; + +if (crewStatus &&& computerStatus === 'green'){ + console.log('Crew & computer cleared.'); + launchReady = true; +} else { + console.log('WARNING: Crew or computer not ready!'); + launchReady = false; +} + +if (launchReady) { + console.log(("10, 9, 8, 7, 6, 5, 4, 3, 2, 1..."); + console.log("Fed parrot..."); + console.log("Ignition..."); + console.log("Liftoff!"); +} else { + console.log("Launch scrubbed."); +} \ No newline at end of file From 8401b7a4d39471be69141ed6a8335c3432d32a78 Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Tue, 15 Aug 2023 11:48:40 -0500 Subject: [PATCH 06/46] starter code for functions studio --- functions/studio/studio-functions.js | 51 ++++++++++++++++++++++++++++ functions/try-it/isPalindrome.js | 7 ++++ functions/try-it/printMessage.js | 10 ++++++ functions/try-it/reverse.js | 5 +++ functions/try-it/sayHello.js | 3 ++ 5 files changed, 76 insertions(+) create mode 100644 functions/studio/studio-functions.js create mode 100644 functions/try-it/isPalindrome.js create mode 100644 functions/try-it/printMessage.js create mode 100644 functions/try-it/reverse.js create mode 100644 functions/try-it/sayHello.js diff --git a/functions/studio/studio-functions.js b/functions/studio/studio-functions.js new file mode 100644 index 0000000000..d4c291ed1a --- /dev/null +++ b/functions/studio/studio-functions.js @@ -0,0 +1,51 @@ +//We want to COMPLETELY reverse an array by flipping the order of the entries AND flipping the order of characters in each element. + +// Part One: Reverse Characters + +// 1. Define the function as reverseCharacters. Give it one parameter, which will be the string to reverse. +// 2. Within the function, split the string into an array, then reverse the array. +// 3. Use join to create the reversed string and return that string from the function. +// 4. Below the function, define and initialize a variable to hold a string. +// 5. Use console.log(reverseCharacters(myVariableName)); to call the function and verify that it correctly reverses the characters in the string. +// 6. Optional: Use method chaining to reduce the lines of code within the function. + +// Part Two: Reverse Digits + +// 1. Add an if statement to reverseCharacters to check the typeof the parameter. +// 2. If typeof is ‘string’, return the reversed string as before. +// 3. If typeof is ’number’, convert the parameter to a string, reverse the characters, then convert it back into a number. +// 4. Return the reversed number. +// 5. Be sure to print the result returned by the function to verify that your code works for both strings and numbers. Do this before moving on to the next exercise. + +// Part Three: Complete Reversal + +// 1. Define and initialize an empty array. +// 2. Loop through the old array. +// 3. For each element in the old array, call reverseCharacters to flip the characters or digits. +// 4. Add the reversed string (or number) to the array defined in part ‘a’. +// 5. Return the final, reversed array. +// 6. Be sure to print the results from each test case in order to verify your code. + +let arrayTest1 = ['apple', 'potato', 'Capitalized Words']; +let arrayTest2 = [123, 8897, 42, 1168, 8675309]; +let arrayTest3 = ['hello', 'world', 123, 'orange']; + +// Bonus Missions + +// 1. Have a clear, descriptive name like funPhrase. +// 2. Retrieve only the last character from strings with lengths of 3 or less. +// 3. Retrieve only the first 3 characters from strings with lengths larger than 3. +// 4. Use a template literal to return the phrase We put the '___' in '___'. Fill the first blank with the modified string, and fill the second blank with the original string. + +// Test Function + +// 1. Outside of the function, define the variable str and initialize it with a string (e.g. 'Functions rock!'). +// 2. Call your function and print the returned phrase. + +// Area of rectangle equal to length x width + +// 1. Define a function with the required parameters to calculate the area of a rectangle. +// 2. The function should return the area, NOT print it. +// 3. Call your area function by passing in two arguments - the length and width. +// 4. If only one argument is passed to the function, then the shape is a square. Modify your code to deal with this case. +// 5. Use a template literal to print, “The area is ____ cm^2.” diff --git a/functions/try-it/isPalindrome.js b/functions/try-it/isPalindrome.js new file mode 100644 index 0000000000..e4565d063a --- /dev/null +++ b/functions/try-it/isPalindrome.js @@ -0,0 +1,7 @@ +function reverse(str) { + return str.split('').reverse().join(''); +} + +function isPalindrome(str) { + return reverse(str) === str; +} diff --git a/functions/try-it/printMessage.js b/functions/try-it/printMessage.js new file mode 100644 index 0000000000..ad34b0067f --- /dev/null +++ b/functions/try-it/printMessage.js @@ -0,0 +1,10 @@ +let message = "Hello, World!"; + +function printMessage() { + console.log(message); +} + +printMessage(); +message = "Goodbye"; +printMessage(); + diff --git a/functions/try-it/reverse.js b/functions/try-it/reverse.js new file mode 100644 index 0000000000..5673fcf1c1 --- /dev/null +++ b/functions/try-it/reverse.js @@ -0,0 +1,5 @@ +function reverse(str) { + let lettersArray = str.split(''); + let reversedLettersArray = lettersArray.reverse(); + return reversedLettersArray.join(''); +} diff --git a/functions/try-it/sayHello.js b/functions/try-it/sayHello.js new file mode 100644 index 0000000000..1b6cb75e80 --- /dev/null +++ b/functions/try-it/sayHello.js @@ -0,0 +1,3 @@ +function sayHello() { + console.log("Hello, World!"); +} From 365007eab5e37f6b1c6b108e3e79382ba1890eaa Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Wed, 16 Aug 2023 10:45:42 -0500 Subject: [PATCH 07/46] added degrees c-to-k per todo --- errors-and-debugging/chapter-examples/degrees-c-to-k.js | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 errors-and-debugging/chapter-examples/degrees-c-to-k.js diff --git a/errors-and-debugging/chapter-examples/degrees-c-to-k.js b/errors-and-debugging/chapter-examples/degrees-c-to-k.js new file mode 100644 index 0000000000..7c6f310cbb --- /dev/null +++ b/errors-and-debugging/chapter-examples/degrees-c-to-k.js @@ -0,0 +1,6 @@ +const input = require('readline-sync'); + +let degreesC = input.question('Temp in degrees C: '); +let degreesK = degreesC + 273.15; + +console.log('Degrees K:', degreesK); From 10ace97b662fd413aed784c13ceab4f423edc74a Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Wed, 23 Aug 2023 15:39:28 -0500 Subject: [PATCH 08/46] added chapter example code for chapter 4, also added package.json for readline-sync --- .../chapter-examples/bruces-beard.js | 1 + .../chapter-examples/critical-input-detail.js | 6 ++++++ .../chapter-examples/more-on-numbers.js | 5 +++++ .../chapter-examples/more-on-strings.js | 5 +++++ data-and-variables/chapter-examples/package.json | 15 +++++++++++++++ .../chapter-examples/readline-greeting-program.js | 3 +++ .../chapter-examples/readline-sync.js | 3 +++ .../chapter-examples/type-conversion.js | 9 +++++++++ data-and-variables/chapter-examples/type-of.js | 3 +++ 9 files changed, 50 insertions(+) create mode 100644 data-and-variables/chapter-examples/bruces-beard.js create mode 100644 data-and-variables/chapter-examples/critical-input-detail.js create mode 100644 data-and-variables/chapter-examples/more-on-numbers.js create mode 100644 data-and-variables/chapter-examples/more-on-strings.js create mode 100644 data-and-variables/chapter-examples/package.json create mode 100644 data-and-variables/chapter-examples/readline-greeting-program.js create mode 100644 data-and-variables/chapter-examples/readline-sync.js create mode 100644 data-and-variables/chapter-examples/type-conversion.js create mode 100644 data-and-variables/chapter-examples/type-of.js diff --git a/data-and-variables/chapter-examples/bruces-beard.js b/data-and-variables/chapter-examples/bruces-beard.js new file mode 100644 index 0000000000..5b4352ebb8 --- /dev/null +++ b/data-and-variables/chapter-examples/bruces-beard.js @@ -0,0 +1 @@ +console.log('Bruce's beard'); diff --git a/data-and-variables/chapter-examples/critical-input-detail.js b/data-and-variables/chapter-examples/critical-input-detail.js new file mode 100644 index 0000000000..c69c17457c --- /dev/null +++ b/data-and-variables/chapter-examples/critical-input-detail.js @@ -0,0 +1,6 @@ +const input = require('readline-sync'); + +let num1 = input.question("Enter a number: "); +let num2 = input.question("Enter another number: "); + +console.log(num1 + num2); diff --git a/data-and-variables/chapter-examples/more-on-numbers.js b/data-and-variables/chapter-examples/more-on-numbers.js new file mode 100644 index 0000000000..f427dc8f19 --- /dev/null +++ b/data-and-variables/chapter-examples/more-on-numbers.js @@ -0,0 +1,5 @@ +console.log(42000); +console.log(42,000); + +console.log(42, 17, 56, 34, 11, 4.35, 32); +console.log(3.4, "hello", 45); diff --git a/data-and-variables/chapter-examples/more-on-strings.js b/data-and-variables/chapter-examples/more-on-strings.js new file mode 100644 index 0000000000..cc5553bd96 --- /dev/null +++ b/data-and-variables/chapter-examples/more-on-strings.js @@ -0,0 +1,5 @@ +console.log(typeof "17"); +console.log(typeof "3.2"); + +console.log(typeof 'This is a string'); +console.log(typeof "And so is this"); diff --git a/data-and-variables/chapter-examples/package.json b/data-and-variables/chapter-examples/package.json new file mode 100644 index 0000000000..51f40e64e7 --- /dev/null +++ b/data-and-variables/chapter-examples/package.json @@ -0,0 +1,15 @@ +{ + "name": "Dependencies for Chapter 4: Data and Variables", + "version": "1.0.0", + "description": "This package.json file includes all dependencies needed to run code within files contained in this directory", + "main": "index.js", + "dependencies": { + "readline-sync": "^1.4.10" + }, + "scripts": { + "start": "node index.js" + }, + "author": "John Woolbright", + "license": "ISC" +} + diff --git a/data-and-variables/chapter-examples/readline-greeting-program.js b/data-and-variables/chapter-examples/readline-greeting-program.js new file mode 100644 index 0000000000..c46b8bae2b --- /dev/null +++ b/data-and-variables/chapter-examples/readline-greeting-program.js @@ -0,0 +1,3 @@ +const input = require('readline-sync'); + +let name = input.question("Enter your name: "); diff --git a/data-and-variables/chapter-examples/readline-sync.js b/data-and-variables/chapter-examples/readline-sync.js new file mode 100644 index 0000000000..02d855a111 --- /dev/null +++ b/data-and-variables/chapter-examples/readline-sync.js @@ -0,0 +1,3 @@ +const input = require('readline-sync'); + +let info = input.question("Question text... "); diff --git a/data-and-variables/chapter-examples/type-conversion.js b/data-and-variables/chapter-examples/type-conversion.js new file mode 100644 index 0000000000..adccdc3d06 --- /dev/null +++ b/data-and-variables/chapter-examples/type-conversion.js @@ -0,0 +1,9 @@ +console.log(Number("2345")); +console.log(typeof Number("2345")); +console.log(Number(17)); + +console.log(Number("23bottles")); + +console.log(String(17)); +console.log(String(123.45)); +console.log(typeof String(123.45)); diff --git a/data-and-variables/chapter-examples/type-of.js b/data-and-variables/chapter-examples/type-of.js new file mode 100644 index 0000000000..777f5f21c0 --- /dev/null +++ b/data-and-variables/chapter-examples/type-of.js @@ -0,0 +1,3 @@ +console.log(typeof "Hello, World!"); +console.log(typeof 17); +console.log(typeof 3.14); From ccb4e741c4b329ad5e82518bb818798a2573c7d4 Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Mon, 28 Aug 2023 12:08:37 -0500 Subject: [PATCH 09/46] array-exercises added --- arrays/exercises/part-five-arrays.js | 11 +++++++++++ arrays/exercises/part-four-arrays.js | 10 ++++++++++ arrays/exercises/part-one-arrays.js | 5 +++++ arrays/exercises/part-six-arrays.js | 11 +++++++++++ arrays/exercises/part-three-arrays.js | 9 +++++++++ arrays/exercises/part-two-arrays.js | 11 +++++++++++ 6 files changed, 57 insertions(+) create mode 100644 arrays/exercises/part-five-arrays.js create mode 100644 arrays/exercises/part-four-arrays.js create mode 100644 arrays/exercises/part-one-arrays.js create mode 100644 arrays/exercises/part-six-arrays.js create mode 100644 arrays/exercises/part-three-arrays.js create mode 100644 arrays/exercises/part-two-arrays.js diff --git a/arrays/exercises/part-five-arrays.js b/arrays/exercises/part-five-arrays.js new file mode 100644 index 0000000000..4cdf1bba41 --- /dev/null +++ b/arrays/exercises/part-five-arrays.js @@ -0,0 +1,11 @@ +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 (). + +//2) Use the join method on the array to identify the purpose of the parameter inside the (). + +//3) Do split or join change the original string/array? + +//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"; diff --git a/arrays/exercises/part-four-arrays.js b/arrays/exercises/part-four-arrays.js new file mode 100644 index 0000000000..498149702e --- /dev/null +++ b/arrays/exercises/part-four-arrays.js @@ -0,0 +1,10 @@ +let holdCabinet1 = ['duct tape', 'gum', 3.14, false, 6.022e23]; +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. + +//2) Print a slice of two elements from each array. Does slice alter the original arrays? + +//3) reverse the first array, and sort the second. What is the difference between these two methods? Do the methods alter the original arrays? diff --git a/arrays/exercises/part-one-arrays.js b/arrays/exercises/part-one-arrays.js new file mode 100644 index 0000000000..85a27f5537 --- /dev/null +++ b/arrays/exercises/part-one-arrays.js @@ -0,0 +1,5 @@ +//Create an array that can hold 4 items name practiceFile. + +//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. + +//Use a SetValue to add the items "false", and "-4.6" to the array. Print the array to confirm the changes. diff --git a/arrays/exercises/part-six-arrays.js b/arrays/exercises/part-six-arrays.js new file mode 100644 index 0000000000..d0a28bed56 --- /dev/null +++ b/arrays/exercises/part-six-arrays.js @@ -0,0 +1,11 @@ +//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. + +//2) Define the array 'table', and use 'push' to add each of the element arrays to it. Print 'table' to see its structure. + +//3) Use bracket notation to examine the difference between printing 'table' with one index vs. two indices (table[][]). + +//4) Using bracket notation and the table array, print the mass of element1, the name for element 2 and the symbol for element26. + +//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. diff --git a/arrays/exercises/part-three-arrays.js b/arrays/exercises/part-three-arrays.js new file mode 100644 index 0000000000..d43918a702 --- /dev/null +++ b/arrays/exercises/part-three-arrays.js @@ -0,0 +1,9 @@ +let cargoHold = [1138, 'space suits', 'parrot', 'instruction manual', 'meal packs', 'space tether', '20 meters']; + +//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. + +//2) Remove ‘instruction manual’ from the array. (Hint: indexOf is helpful to avoid manually counting an index). + +//3) Replace the elements at indexes 2 - 4 with the items ‘cat’, ‘fob’, and ‘string cheese’. diff --git a/arrays/exercises/part-two-arrays.js b/arrays/exercises/part-two-arrays.js new file mode 100644 index 0000000000..a940b1d0ff --- /dev/null +++ b/arrays/exercises/part-two-arrays.js @@ -0,0 +1,11 @@ +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. + +//2) Remove the last item from the array with pop. Print the element removed and the updated array. + +//3) Remove the first item from the array with shift. Print the element removed and the updated array. + +//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. + +//5) Use a template literal to print the final array and its length. From 0251067a6097d3b706ee36cee264c1d6e2c07200 Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Mon, 28 Aug 2023 14:02:09 -0500 Subject: [PATCH 10/46] arrays-studio starter code complete --- .../array-string-conversion/array-testing.js | 54 +++++++++++++++++++ .../studio/array-string-conversion/index.js | 8 +++ .../array-string-conversion/package.json | 19 +++++++ .../spec/array-testing.spec.js | 38 +++++++++++++ arrays/studio/multi-dimensional-arrays.js | 14 +++++ arrays/studio/package.json | 6 +++ arrays/studio/string-modification.js | 11 ++++ 7 files changed, 150 insertions(+) create mode 100644 arrays/studio/array-string-conversion/array-testing.js create mode 100644 arrays/studio/array-string-conversion/index.js create mode 100644 arrays/studio/array-string-conversion/package.json create mode 100644 arrays/studio/array-string-conversion/spec/array-testing.spec.js create mode 100644 arrays/studio/multi-dimensional-arrays.js create mode 100644 arrays/studio/package.json create mode 100644 arrays/studio/string-modification.js diff --git a/arrays/studio/array-string-conversion/array-testing.js b/arrays/studio/array-string-conversion/array-testing.js new file mode 100644 index 0000000000..c4d5899385 --- /dev/null +++ b/arrays/studio/array-string-conversion/array-testing.js @@ -0,0 +1,54 @@ +let protoArray1 = "3,6,9,12"; +let protoArray2 = "A;C;M;E"; +let protoArray3 = "space delimited string"; +let protoArray4 = "Comma-spaces, might, require, typing, caution"; + +strings = [protoArray1, protoArray2, protoArray3, protoArray4]; + +//2) +function reverseCommas() { + //TODO: 1. create and instantiate your variables. + let check; + let output; + //TODO: 2. write the code required for this step + + //NOTE: For the code to run properly, you must return your output. this needs to be the final line of code within the function's { }. + return output; +} + +//3) +function semiDash() { + let check; + let output; +//TODO: write the code required for this step + + + return output; +} + +//4) +function reverseSpaces() { + let check; + let output; + //TODO: write the code required for this step + + return output; +} + +//5) +function commaSpace() { + let check; + let output; + //TODO: write the code required for this step + + return output; +} + +// NOTE: Don't add or modify any code below this line or your program might not run as expected. +module.exports = { + strings : strings, + reverseCommas : reverseCommas, + semiDash: semiDash, + reverseSpaces : reverseSpaces, + commaSpace : commaSpace +}; diff --git a/arrays/studio/array-string-conversion/index.js b/arrays/studio/array-string-conversion/index.js new file mode 100644 index 0000000000..f474f2dace --- /dev/null +++ b/arrays/studio/array-string-conversion/index.js @@ -0,0 +1,8 @@ +const studio = require('./array-testing'); + +console.log(studio.reverseCommas()); +console.log(studio.semiDash()); +console.log(studio.reverseSpaces()); +console.log(studio.commaSpace()); + +//NOTE: open the array-testing.js file to begin coding diff --git a/arrays/studio/array-string-conversion/package.json b/arrays/studio/array-string-conversion/package.json new file mode 100644 index 0000000000..f601a02361 --- /dev/null +++ b/arrays/studio/array-string-conversion/package.json @@ -0,0 +1,19 @@ +{ + "name": "Array and String Conversion", + "version": "1.0.0", + "description": "intro to prof web dev studio: Arrays Keep Things in Order", + "main": "grading.js", + "scripts": { + "test": "jest" + }, + "author": "", + "license": "ISC", + "devDependencies": { + "@testing-library/jest-dom": "^5.16.5", + "jest": "^29.6.1", + "jest-environment-jsdom": "^29.6.1" + }, + "overrides": { + "semver": "~7.5.2" + } +} diff --git a/arrays/studio/array-string-conversion/spec/array-testing.spec.js b/arrays/studio/array-string-conversion/spec/array-testing.spec.js new file mode 100644 index 0000000000..0e1581d62e --- /dev/null +++ b/arrays/studio/array-string-conversion/spec/array-testing.spec.js @@ -0,0 +1,38 @@ +/** + * @jest-environment node + */ + +const fs = require('fs'); +const path = require("path"); +const { JSDOM } = require("jsdom"); +const { window } = new JSDOM(fs.readFileSync(path.resolve(__dirname, "../index.js"), 'utf8')); +const { document } = window; +const { screen } = require('@testing-library/jest-dom'); + +//NOTE: Do NOT modify any of the code below. + +//These are the tests. To run them and check your own status, type "npm test" into the console. Running tests is optional. +const solution = require('../array-testing'); + +describe("Array Studio Solution", function() { + + it("strings[0] is '12,9,6,3' after method chaining", function() { + let testArray = solution.reverseCommas(strings[0]); + expect(testArray).toBe("12,9,6,3"); + }); + + it("strings[1] is 'A-C-E-M' after method chaining", function() { + let testArray = solution.semiDash(strings[1]); + expect(testArray).toBe("A-C-E-M"); + }); + + it("strings[2] is 'string space deliminated' after method chaining", function() { + let testArray = solution.reverseSpaces(strings[2]); + expect(testArray).toBe("string space delimited"); + }); + + it("string[3] is 'caution,typing,require,might,Comma-spaces' after method chaining", function() { + let testArray = solution.commaSpace(strings[3]); + expect(testArray).toBe("caution,typing,require,might,Comma-spaces"); + }); +}); diff --git a/arrays/studio/multi-dimensional-arrays.js b/arrays/studio/multi-dimensional-arrays.js new file mode 100644 index 0000000000..18761a8934 --- /dev/null +++ b/arrays/studio/multi-dimensional-arrays.js @@ -0,0 +1,14 @@ +let food = "water bottles,meal packs,snacks,chocolate"; +let equipment = "space suits,jet packs,tool belts,thermal detonators"; +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. + +//2) Initialize a cargoHold array and add the cabinet arrays to it. Print cargoHold to verify its structure. + +//3) Query the user to select a cabinet (0 - 3) in the cargoHold. + +//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. + +//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/package.json b/arrays/studio/package.json new file mode 100644 index 0000000000..b7dcd099d4 --- /dev/null +++ b/arrays/studio/package.json @@ -0,0 +1,6 @@ +{ + "main": "index.js", + "dependencies": { + "readline-sync": "1.4.9" + } +} diff --git a/arrays/studio/string-modification.js b/arrays/studio/string-modification.js new file mode 100644 index 0000000000..45991b15fc --- /dev/null +++ b/arrays/studio/string-modification.js @@ -0,0 +1,11 @@ +const input = require('readline-sync'); +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. + +//Use a template literal to print the original and modified string in a descriptive phrase. + +//2) Modify your code to accept user input. Query the user to enter the number of letters that will be relocated. + +//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. From 3835f1304e2de5d996919e13715e645eef9dd082 Mon Sep 17 00:00:00 2001 From: Sally Steuterman Date: Tue, 29 Aug 2023 11:36:50 -0500 Subject: [PATCH 11/46] Setting up starter code for Chapter 9 --- loops/chapter-examples/Loop-Variable.js | 5 +++++ loops/chapter-examples/Reversing-a-String.js | 8 ++++++++ loops/chapter-examples/for-Loop-Practice-With-Arrays.js | 3 +++ loops/chapter-examples/for-Loop-Practice-With-Strings.js | 4 ++++ loops/chapter-examples/while-Loop-Example.js | 6 ++++++ 5 files changed, 26 insertions(+) create mode 100644 loops/chapter-examples/Loop-Variable.js create mode 100644 loops/chapter-examples/Reversing-a-String.js create mode 100644 loops/chapter-examples/for-Loop-Practice-With-Arrays.js create mode 100644 loops/chapter-examples/for-Loop-Practice-With-Strings.js create mode 100644 loops/chapter-examples/while-Loop-Example.js diff --git a/loops/chapter-examples/Loop-Variable.js b/loops/chapter-examples/Loop-Variable.js new file mode 100644 index 0000000000..3b00ba56c4 --- /dev/null +++ b/loops/chapter-examples/Loop-Variable.js @@ -0,0 +1,5 @@ +// Experiment with this loop by modifying each of the following: the variable initialization, the boolean condition, and the update expression. + +for (let i = 0; i < 51; i++) { + console.log(i); + } \ No newline at end of file diff --git a/loops/chapter-examples/Reversing-a-String.js b/loops/chapter-examples/Reversing-a-String.js new file mode 100644 index 0000000000..9044c0293f --- /dev/null +++ b/loops/chapter-examples/Reversing-a-String.js @@ -0,0 +1,8 @@ +let str = "blue"; +let reversed = ""; + +for (let i = 0; i < str.length; i++) { + reversed = str[i] + reversed; +} + +console.log(reversed); \ No newline at end of file diff --git a/loops/chapter-examples/for-Loop-Practice-With-Arrays.js b/loops/chapter-examples/for-Loop-Practice-With-Arrays.js new file mode 100644 index 0000000000..c463f79138 --- /dev/null +++ b/loops/chapter-examples/for-Loop-Practice-With-Arrays.js @@ -0,0 +1,3 @@ +// create an array variable containing the names + +// write a for loop that prints each name on a different line diff --git a/loops/chapter-examples/for-Loop-Practice-With-Strings.js b/loops/chapter-examples/for-Loop-Practice-With-Strings.js new file mode 100644 index 0000000000..fc5d5885cc --- /dev/null +++ b/loops/chapter-examples/for-Loop-Practice-With-Strings.js @@ -0,0 +1,4 @@ +// Create a string variable containing your name. + + +// Write a for loop that prints each character in your name on a different line. \ No newline at end of file diff --git a/loops/chapter-examples/while-Loop-Example.js b/loops/chapter-examples/while-Loop-Example.js new file mode 100644 index 0000000000..787971fbe9 --- /dev/null +++ b/loops/chapter-examples/while-Loop-Example.js @@ -0,0 +1,6 @@ +let i = 0; + +while (i < 51) { + console.log(i); + i++; +} \ No newline at end of file From ed9cf5811d684300e6dedd9213acc5a6b4e91df0 Mon Sep 17 00:00:00 2001 From: Sally Steuterman Date: Tue, 29 Aug 2023 13:49:26 -0500 Subject: [PATCH 12/46] Adding exercises and studio --- loops/exercises/for-Loop-Exercises.js | 24 +++++++ loops/exercises/while-Loop-Exercises.js | 25 ++++++++ loops/studio/index.js | 3 + loops/studio/package.json | 17 +++++ loops/studio/solution.js | 78 +++++++++++++++++++++++ loops/studio/spec/solution.spec.js | 83 +++++++++++++++++++++++++ 6 files changed, 230 insertions(+) create mode 100644 loops/exercises/for-Loop-Exercises.js create mode 100644 loops/exercises/while-Loop-Exercises.js create mode 100644 loops/studio/index.js create mode 100644 loops/studio/package.json create mode 100644 loops/studio/solution.js create mode 100644 loops/studio/spec/solution.spec.js diff --git a/loops/exercises/for-Loop-Exercises.js b/loops/exercises/for-Loop-Exercises.js new file mode 100644 index 0000000000..c659c50852 --- /dev/null +++ b/loops/exercises/for-Loop-Exercises.js @@ -0,0 +1,24 @@ +/*Exercise #1: Construct for loops that accomplish the following tasks: + a. Print the numbers 0 - 20, one number per line. + b. Print only the ODD values from 3 - 29, one number per line. + c. Print the EVEN numbers 12 to -14 in descending order, one number per line. + d. Challenge - Print the numbers 50 - 20 in descending order, but only if the numbers are multiples of 3. (Your code should work even if you replace 50 or 20 with other numbers). */ + + + + +/*Exercise #2: +Initialize two variables to hold the string “LaunchCode” and the array [1, 5, ‘LC101’, ‘blue’, 42]. + + +Construct ``for`` loops to accomplish the following tasks: + a. Print each element of the array to a new line. + b. Print each character of the string - in reverse order - to a new line. */ + + + + + +/*Exercise #3:Construct a for loop that sorts the array [2, 3, 13, 18, -5, 38, -10, 11, 0, 104] into two new arrays: + a. One array contains the even numbers, and the other holds the odds. + b. Print the arrays to confirm the results. */ \ No newline at end of file diff --git a/loops/exercises/while-Loop-Exercises.js b/loops/exercises/while-Loop-Exercises.js new file mode 100644 index 0000000000..53a8ce1250 --- /dev/null +++ b/loops/exercises/while-Loop-Exercises.js @@ -0,0 +1,25 @@ +//Define three variables for the LaunchCode shuttle - one for the starting fuel level, another for the number of astronauts aboard, and the third for the altitude the shuttle reaches. + + + + + +/*Exercise #4: Construct while loops to do the following: + a. Query the user for the starting fuel level. Validate that the user enters a positive, integer value greater than 5000 but less than 30000. */ + + + + + +//b. Use a second loop to query the user for the number of astronauts (up to a maximum of 7). Validate the entry. + + + + +//c. Use a final loop to monitor the fuel status and the altitude of the shuttle. Each iteration, decrease the fuel level by 100 units for each astronaut aboard. Also, increase the altitude by 50 kilometers. + + + +/*Exercise #5: Output the result with the phrase, “The shuttle gained an altitude of ___ km.” + +If the altitude is 2000 km or higher, add “Orbit achieved!” Otherwise add, “Failed to reach orbit.”*/ diff --git a/loops/studio/index.js b/loops/studio/index.js new file mode 100644 index 0000000000..2f4084291f --- /dev/null +++ b/loops/studio/index.js @@ -0,0 +1,3 @@ +const shuttleManagement = require('./solution.js'); + +shuttleManagement.runProgram(); \ No newline at end of file diff --git a/loops/studio/package.json b/loops/studio/package.json new file mode 100644 index 0000000000..b74d5c248f --- /dev/null +++ b/loops/studio/package.json @@ -0,0 +1,17 @@ +{ + "name": "loops", + "version": "1.0.0", + "description": "", + "main": "solution.js", + "scripts": { + "test": "jest" + }, + "author": "", + "license": "ISC", + "dependencies": { + "readline-sync": "^1.4.10" + }, + "devDependencies": { + "jest": "^29.6.1" + } +} diff --git a/loops/studio/solution.js b/loops/studio/solution.js new file mode 100644 index 0000000000..4e21a9caa5 --- /dev/null +++ b/loops/studio/solution.js @@ -0,0 +1,78 @@ +const input = require('readline-sync'); + +// Part A: #1 Populate these arrays + +let protein = []; +let grains = []; +let veggies = []; +let beverages = []; +let desserts = []; + + +function mealAssembly(protein, grains, veggies, beverages, desserts, numMeals) { + let pantry = [protein, grains, veggies, beverages, desserts]; + let meals = []; + + /// Part A #2: Write a ``for`` loop inside this function + /// Code your solution for part A #2 below this comment (and above the return statement) ... /// + + + return meals; +} + + +function askForNumber() { + numMeals = input.question("How many meals would you like to make?"); + + /// CODE YOUR SOLUTION TO PART B here /// + + return numMeals; +} + + +function generatePassword(string1, string2) { + let code = ''; + + /// Code your Bonus Mission Solution here /// + + return code; +} + +function runProgram() { + + /// TEST PART A #2 HERE /// + /// UNCOMMENT the two lines of code below that invoke the mealAssembly function (starting with 'let meals =') and print the result /// + /// Change the final input variable (aka numMeals) here to ensure your solution makes the right number of meals /// + /// We've started with the number 2 for now. Does your solution still work if you change this value? /// + + // let meals = mealAssembly(protein, grains, veggies, beverages, desserts, 2); + // console.log(meals) + + + /// TEST PART B HERE /// + /// UNCOMMENT the next two lines to test your ``askForNumber`` solution /// + /// Tip - don't test this part until you're happy with your solution to part A #2 /// + + // let mealsForX = mealAssembly(protein, grains, veggies, beverages, desserts, askForNumber()); + // console.log(mealsForX); + + /// TEST PART C HERE /// + /// UNCOMMENT the remaining commented lines and change the password1 and password2 strings to ensure your code is doing its job /// + + // let password1 = ''; + // let password2 = ''; + // console.log("Time to run the password generator so we can update the menu tomorrow.") + // console.log(`The new password is: ${generatePassword(password1, password2)}`); +} + +module.exports = { + protein: protein, + grains: grains, + veggies: veggies, + beverages: beverages, + desserts: desserts, + mealAssembly: mealAssembly, + askForNumber: askForNumber, + generatePassword: generatePassword, + runProgram: runProgram +}; diff --git a/loops/studio/spec/solution.spec.js b/loops/studio/spec/solution.spec.js new file mode 100644 index 0000000000..027c218e36 --- /dev/null +++ b/loops/studio/spec/solution.spec.js @@ -0,0 +1,83 @@ +const studentsolution = require('../solution.js'); + +describe ("Loops studio solution", function() { + + let protein, grains, veggies, beverages, desserts; + + beforeAll(async function () { + protein = studentsolution.protein; + grains = studentsolution.grains; + veggies = studentsolution.veggies; + beverages = studentsolution.beverages; + desserts = studentsolution.desserts; + }); + + + it("desserts is initialized", function() { + expect(desserts).toContain("apple"); + expect(desserts).toContain("banana"); + expect(desserts).toContain("more kale"); + expect(desserts).toContain("ice cream"); + expect(desserts).toContain("chocolate"); + expect(desserts).toContain("kiwi"); + expect(desserts.length).toBe(6); + }); + + it("beverages is initialized", function() { + expect(beverages).toContain("juice"); + expect(beverages).toContain("milk"); + expect(beverages).toContain("water"); + expect(beverages).toContain("soy milk"); + expect(beverages).toContain("soda"); + expect(beverages).toContain("tea"); + expect(beverages.length).toBe(6); + }); + + it("protein is initialized", function () { + expect(protein).toContain("chicken"); + expect(protein).toContain("pork"); + expect(protein).toContain("tofu"); + expect(protein).toContain("beef"); + expect(protein).toContain("fish"); + expect(protein).toContain("beans"); + expect(protein.length).toBe(6); + }); + + it("grains is initialized", function() { + expect(grains).toContain("rice"); + expect(grains).toContain("pasta"); + expect(grains).toContain("corn"); + expect(grains).toContain("potato"); + expect(grains).toContain("quinoa"); + expect(grains).toContain("crackers"); + expect(grains.length).toBe(6); + }); + + it("veggies is initialized", function() { + expect(veggies).toContain("peas"); + expect(veggies).toContain("green beans"); + expect(veggies).toContain("kale"); + expect(veggies).toContain("edamame"); + expect(veggies).toContain("broccoli"); + expect(veggies).toContain("asparagus"); + expect(veggies.length).toBe(6); + }); + + it("mealAssembly produces proper number and size of meals", function() { + let testMeals1 = studentsolution.mealAssembly(protein, grains, veggies, beverages, desserts, 6); + expect(testMeals1.length).toBe(6); + expect(testMeals1[0].length).toBe(5); + let testMeals2 = studentsolution.mealAssembly(protein, grains, veggies, beverages, desserts, 3); + expect(testMeals2.length).toBe(3); + expect(testMeals2[0].length).toBe(5); + let testMeals3 = studentsolution.mealAssembly(protein, grains, veggies, beverages, desserts, 4); + expect(testMeals3.length).toBe(4); + expect(testMeals3[3].length).toBe(5); + }); + + /// BONUS MISSION TEST /// + + // it("generatePassword returns jumbled words", function() { + // expect(studentsolution.generatePassword("LoOt", "oku!")).toEqual("LookOut!"); + // }) +}); \ No newline at end of file From fec3ae24264df1b94f93f4e7b4da8ddf1a55833a Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Thu, 31 Aug 2023 09:48:27 -0500 Subject: [PATCH 13/46] removed unecessary code from studio --- .../array-string-conversion/spec/array-testing.spec.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/arrays/studio/array-string-conversion/spec/array-testing.spec.js b/arrays/studio/array-string-conversion/spec/array-testing.spec.js index 0e1581d62e..3d7d4ea580 100644 --- a/arrays/studio/array-string-conversion/spec/array-testing.spec.js +++ b/arrays/studio/array-string-conversion/spec/array-testing.spec.js @@ -2,13 +2,6 @@ * @jest-environment node */ -const fs = require('fs'); -const path = require("path"); -const { JSDOM } = require("jsdom"); -const { window } = new JSDOM(fs.readFileSync(path.resolve(__dirname, "../index.js"), 'utf8')); -const { document } = window; -const { screen } = require('@testing-library/jest-dom'); - //NOTE: Do NOT modify any of the code below. //These are the tests. To run them and check your own status, type "npm test" into the console. Running tests is optional. From 6c7f197435675829e63d59517eee03f7e6609ec4 Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Thu, 31 Aug 2023 15:26:26 -0500 Subject: [PATCH 14/46] added chapter examples and restructured directory restructured directory due to the amount of examples included within the chapter --- .../anonymous-functions/package.json | 15 +++++++++++++ .../refactor-to-anonymous.js | 7 +++++++ .../userInput-is-negative.js | 10 +++++++++ .../decreasingSum.js | 9 ++++++++ .../function-calls-itself.js | 16 ++++++++++++++ .../chapter-examples/package.json | 15 +++++++++++++ .../delayed-message.js | 5 +++++ .../halve-each-number.js | 7 +++++++ .../map-array-of-strings.js | 7 +++++++ .../package.json | 15 +++++++++++++ .../function-type-error.js | 5 +++++ .../getValidInput.js | 21 +++++++++++++++++++ .../receieve-function-arguments/package.json | 15 +++++++++++++ .../recursion-base-case/factorial.js | 13 ++++++++++++ .../recursion-base-case/removeI.js | 12 +++++++++++ 15 files changed, 172 insertions(+) create mode 100644 more-on-functions/chapter-examples/anonymous-functions/package.json create mode 100644 more-on-functions/chapter-examples/anonymous-functions/refactor-to-anonymous.js create mode 100644 more-on-functions/chapter-examples/anonymous-functions/userInput-is-negative.js create mode 100644 more-on-functions/chapter-examples/make-function-call-itself/decreasingSum.js create mode 100644 more-on-functions/chapter-examples/make-function-call-itself/function-calls-itself.js create mode 100644 more-on-functions/chapter-examples/package.json create mode 100644 more-on-functions/chapter-examples/passing-functions-as-arguments/delayed-message.js create mode 100644 more-on-functions/chapter-examples/passing-functions-as-arguments/halve-each-number.js create mode 100644 more-on-functions/chapter-examples/passing-functions-as-arguments/map-array-of-strings.js create mode 100644 more-on-functions/chapter-examples/passing-functions-as-arguments/package.json create mode 100644 more-on-functions/chapter-examples/receieve-function-arguments/function-type-error.js create mode 100644 more-on-functions/chapter-examples/receieve-function-arguments/getValidInput.js create mode 100644 more-on-functions/chapter-examples/receieve-function-arguments/package.json create mode 100644 more-on-functions/chapter-examples/recursion-base-case/factorial.js create mode 100644 more-on-functions/chapter-examples/recursion-base-case/removeI.js diff --git a/more-on-functions/chapter-examples/anonymous-functions/package.json b/more-on-functions/chapter-examples/anonymous-functions/package.json new file mode 100644 index 0000000000..6a6e828902 --- /dev/null +++ b/more-on-functions/chapter-examples/anonymous-functions/package.json @@ -0,0 +1,15 @@ +{ + "name": "Chapter 11: More on Functions Chapter Examples Directory", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "readline-sync": "^1.4.10" + } +} diff --git a/more-on-functions/chapter-examples/anonymous-functions/refactor-to-anonymous.js b/more-on-functions/chapter-examples/anonymous-functions/refactor-to-anonymous.js new file mode 100644 index 0000000000..3276e3bd8a --- /dev/null +++ b/more-on-functions/chapter-examples/anonymous-functions/refactor-to-anonymous.js @@ -0,0 +1,7 @@ +function reverse(str) { + let lettersArray = str.split(''); + let reversedLettersArray = lettersArray.reverse(); + return reversedLettersArray.join(''); +} + +console.log(reverse("LaunchCode")); diff --git a/more-on-functions/chapter-examples/anonymous-functions/userInput-is-negative.js b/more-on-functions/chapter-examples/anonymous-functions/userInput-is-negative.js new file mode 100644 index 0000000000..2589ff8aa7 --- /dev/null +++ b/more-on-functions/chapter-examples/anonymous-functions/userInput-is-negative.js @@ -0,0 +1,10 @@ +const input = require('readline-sync'); +let userInput = input.question("Please enter a number:"); +let logger = function(errorMsg) { + console.log("ERROR: " + errorMsg); +}; +if (userInput < 0) { + // ______("Invalid input"); +} + +// Fill in the blank in line 7 (then uncomment it) so that it logs an error message if userInput is negative. diff --git a/more-on-functions/chapter-examples/make-function-call-itself/decreasingSum.js b/more-on-functions/chapter-examples/make-function-call-itself/decreasingSum.js new file mode 100644 index 0000000000..c269fa6bbf --- /dev/null +++ b/more-on-functions/chapter-examples/make-function-call-itself/decreasingSum.js @@ -0,0 +1,9 @@ +function decreasingSum(integer) { + if (integer === 1){ + return integer; + } else { + //call decreasingSum function again + } +} + +console.log(decreasingSum(5)); diff --git a/more-on-functions/chapter-examples/make-function-call-itself/function-calls-itself.js b/more-on-functions/chapter-examples/make-function-call-itself/function-calls-itself.js new file mode 100644 index 0000000000..799b2499f4 --- /dev/null +++ b/more-on-functions/chapter-examples/make-function-call-itself/function-calls-itself.js @@ -0,0 +1,16 @@ +function combineEntries(arrayName) { + if (arrayName.length <= 1){ + return arrayName[0]; + } else { + //console.log(arrayName[0], arrayName.slice(1)); + return arrayName[0] + combineEntries(arrayName.slice(1)); + } +} + +//First, run the code to see the result. + +//Next, uncomment the console.log statement above to see how each call to combineEntries looks at a different section of the original array. + +let arr = ['L', 'C', '1', '0', '1']; + +console.log(combineEntries(arr)); diff --git a/more-on-functions/chapter-examples/package.json b/more-on-functions/chapter-examples/package.json new file mode 100644 index 0000000000..6a6e828902 --- /dev/null +++ b/more-on-functions/chapter-examples/package.json @@ -0,0 +1,15 @@ +{ + "name": "Chapter 11: More on Functions Chapter Examples Directory", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "readline-sync": "^1.4.10" + } +} diff --git a/more-on-functions/chapter-examples/passing-functions-as-arguments/delayed-message.js b/more-on-functions/chapter-examples/passing-functions-as-arguments/delayed-message.js new file mode 100644 index 0000000000..47bdddda0b --- /dev/null +++ b/more-on-functions/chapter-examples/passing-functions-as-arguments/delayed-message.js @@ -0,0 +1,5 @@ +function printMessage() { + console.log("The future is now!"); +} + +setTimeout(printMessage, 5000); diff --git a/more-on-functions/chapter-examples/passing-functions-as-arguments/halve-each-number.js b/more-on-functions/chapter-examples/passing-functions-as-arguments/halve-each-number.js new file mode 100644 index 0000000000..2591eba089 --- /dev/null +++ b/more-on-functions/chapter-examples/passing-functions-as-arguments/halve-each-number.js @@ -0,0 +1,7 @@ +let nums = [3.14, 42, 4811]; + +// TODO: Write a mapping function +// and pass it to .map() +let halved = nums.map(); + +console.log(halved); diff --git a/more-on-functions/chapter-examples/passing-functions-as-arguments/map-array-of-strings.js b/more-on-functions/chapter-examples/passing-functions-as-arguments/map-array-of-strings.js new file mode 100644 index 0000000000..7dac0d2e92 --- /dev/null +++ b/more-on-functions/chapter-examples/passing-functions-as-arguments/map-array-of-strings.js @@ -0,0 +1,7 @@ +let names = ["Chris", "Jim", "Sally", "Blake", "Paul", "John", "Courtney", "Carly"]; + +// TODO: Write a mapping function +// and pass it to .map() +let firstInitials = names.map(); + +console.log(firstInitials); diff --git a/more-on-functions/chapter-examples/passing-functions-as-arguments/package.json b/more-on-functions/chapter-examples/passing-functions-as-arguments/package.json new file mode 100644 index 0000000000..6a6e828902 --- /dev/null +++ b/more-on-functions/chapter-examples/passing-functions-as-arguments/package.json @@ -0,0 +1,15 @@ +{ + "name": "Chapter 11: More on Functions Chapter Examples Directory", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "readline-sync": "^1.4.10" + } +} diff --git a/more-on-functions/chapter-examples/receieve-function-arguments/function-type-error.js b/more-on-functions/chapter-examples/receieve-function-arguments/function-type-error.js new file mode 100644 index 0000000000..4f042d75a9 --- /dev/null +++ b/more-on-functions/chapter-examples/receieve-function-arguments/function-type-error.js @@ -0,0 +1,5 @@ +function callMe(func) { + func(); +} + +callMe("Al"); diff --git a/more-on-functions/chapter-examples/receieve-function-arguments/getValidInput.js b/more-on-functions/chapter-examples/receieve-function-arguments/getValidInput.js new file mode 100644 index 0000000000..22ed3db504 --- /dev/null +++ b/more-on-functions/chapter-examples/receieve-function-arguments/getValidInput.js @@ -0,0 +1,21 @@ +const input = require('readline-sync'); + +function getValidInput(prompt, isValid) { + + let userInput = input.question(prompt); + + while (!isValid(userInput)) { + console.log("Invalid input. Try again."); + userInput = input.question(prompt); + } + + return userInput; +} + +// TODO 1: write a validator +// that ensures input starts with "a" + +// TODO 2: write a validator +// that ensures input is a vowel + +// Be sure to test your code! diff --git a/more-on-functions/chapter-examples/receieve-function-arguments/package.json b/more-on-functions/chapter-examples/receieve-function-arguments/package.json new file mode 100644 index 0000000000..6a6e828902 --- /dev/null +++ b/more-on-functions/chapter-examples/receieve-function-arguments/package.json @@ -0,0 +1,15 @@ +{ + "name": "Chapter 11: More on Functions Chapter Examples Directory", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "readline-sync": "^1.4.10" + } +} diff --git a/more-on-functions/chapter-examples/recursion-base-case/factorial.js b/more-on-functions/chapter-examples/recursion-base-case/factorial.js new file mode 100644 index 0000000000..0426183130 --- /dev/null +++ b/more-on-functions/chapter-examples/recursion-base-case/factorial.js @@ -0,0 +1,13 @@ +//The following concept check assumes that only positive integers are passed to the function. + +function factorial(integer){ + if (/*enter base case test here*/){ + return integer; + } else { + return integer*(factorial(integer-1)); + } +} + +console.log(factorial(4)); + +//Skill boost! Add validation to return an error message if the function is passed a string, negative number or a decimal value. diff --git a/more-on-functions/chapter-examples/recursion-base-case/removeI.js b/more-on-functions/chapter-examples/recursion-base-case/removeI.js new file mode 100644 index 0000000000..2b83947afe --- /dev/null +++ b/more-on-functions/chapter-examples/recursion-base-case/removeI.js @@ -0,0 +1,12 @@ +function removeI(arr) { + if (/* Enter base case test here */){ + return arr; + } else { + arr.splice(arr.indexOf('i'),1); + return removeI(arr); + } +}; + +let arrayToChange = ['One', 'i', 'c', 'X', 'i', 'i', 54]; + +console.log(removeI(arrayToChange)); From a0ae00919495548688c18679d177e6e4ae9eaf29 Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Tue, 5 Sep 2023 10:02:30 -0500 Subject: [PATCH 15/46] added exercises starter code --- .../exercises/practice-your-skills.js | 15 +++++ more-on-functions/exercises/raid-a-shuttle.js | 57 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 more-on-functions/exercises/practice-your-skills.js create mode 100644 more-on-functions/exercises/raid-a-shuttle.js diff --git a/more-on-functions/exercises/practice-your-skills.js b/more-on-functions/exercises/practice-your-skills.js new file mode 100644 index 0000000000..060f0f03a4 --- /dev/null +++ b/more-on-functions/exercises/practice-your-skills.js @@ -0,0 +1,15 @@ +//Create an anonymous function and set it equal to a variable. + +/* Your function should: +a) If passed a number, return the tripled value. +b) If passed a string, return the string “ARRR!” +c) Be sure to test your function before moving on the next part. +*/ + +/* Add to your code! Use your fuction and the map method to change an array as follows: +a) Triple any the numbers. +b) Replace any strings with “ARRR!” +c) Print the new array to confirm your work. +*/ + +let arr = ['Elocution', 21, 'Clean teeth', 100]; diff --git a/more-on-functions/exercises/raid-a-shuttle.js b/more-on-functions/exercises/raid-a-shuttle.js new file mode 100644 index 0000000000..507a67ccc5 --- /dev/null +++ b/more-on-functions/exercises/raid-a-shuttle.js @@ -0,0 +1,57 @@ +function checkFuel(level) { + if (level > 100000){ + return 'green'; + } else if (level > 50000){ + return 'yellow'; + } else { + return 'red'; + } +} + +function holdStatus(arr){ + if (arr.length < 7) { + return `Spaces available: ${7-arr.length}.`; + } else if (arr.length > 7){ + return `Over capacity by ${arr.length-7} items.`; + } else { + return "Full"; + } +} + +let fuelLevel = 200000; +let cargoHold = ['meal kits', 'space suits', 'first-aid kit', 'satellite', 'gold', 'water', 'AE-35 unit']; + +console.log("Fuel level: " + checkFuel(fuelLevel)); +console.log("Hold status: " + holdStatus(cargoHold)); + +/* Steal some fuel from the shuttle: + * / + +//a). Define an anonymous function and set it equal to a variable with a normal, non-suspicious name. The function takes one parameter. This will be the fuel level on the shuttle. + +//b). You must siphon off fuel without alerting the TAs. Inside your function, you want to reduce the fuel level as much as possible WITHOUT changing the color returned by the checkFuel function. + +//c). Once you figure out how much fuel to pump out, return that value. + +//d). Decide where to best place your function call to gather our new fuel. + +/* Next, liberate some of that glorious cargo. + * / + +//a). Define another anonymous function with an array as a parameter, and set it equal to another innocent variable. + +//b). You need to swipe two items from the cargo hold. Choose well. Stealing water ain’t gonna get us rich. Put the swag into a new array and return it from the function. + +//c). The cargo hold has better security than the fuel tanks. It counts how many things are in storage. You need to replace what you steal with something worthless. The count MUST stay the same, or you’ll get caught and thrown into the LaunchCode brig. + +//d). Don’t get hasty, matey! Remember to test your function. + +/* Finally, you need to print a receipt for the accountant. Don’t laugh! That genius knows MATH and saves us more gold than you can imagine. + * / + +//a). Define a function called irs that can take fuelLevel and cargoHold as arguments. + +//b). Call your anonymous fuel and cargo functions from within irs. + +//c). Use a template literal to return, "Raided _____ kg of fuel from the tanks, and stole ____ and ____ from the cargo hold." + From 2cf9110271cce754c370f8dec6428295d4296585 Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Tue, 5 Sep 2023 10:09:48 -0500 Subject: [PATCH 16/46] completed studio starter code --- .../studio/part-one-find-minimum-value.js | 10 +++++++ .../part-three-number-sorting-easy-way.js | 8 +++++ .../studio/part-two-create-sorted-array.js | 29 +++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 more-on-functions/studio/part-one-find-minimum-value.js create mode 100644 more-on-functions/studio/part-three-number-sorting-easy-way.js create mode 100644 more-on-functions/studio/part-two-create-sorted-array.js diff --git a/more-on-functions/studio/part-one-find-minimum-value.js b/more-on-functions/studio/part-one-find-minimum-value.js new file mode 100644 index 0000000000..4fa8c129d0 --- /dev/null +++ b/more-on-functions/studio/part-one-find-minimum-value.js @@ -0,0 +1,10 @@ +//1) Create a function with an array of numbers as its parameter. The function should iterate through the array and return the minimum value from the array. Hint: Use what you know about if statements to identify and store the smallest value within the array. + +//Sample arrays for testing: +let nums1 = [5, 10, 2, 42]; +let nums2 = [-2, 0, -10, -44, 5, 3, 0, 3]; +let nums3 = [200, 5, 4, 10, 8, 5, -3.3, 4.4, 0]; + +//Using one of the test arrays as the argument, call your function inside the console.log statement below. + +console.log(/* your code here */); diff --git a/more-on-functions/studio/part-three-number-sorting-easy-way.js b/more-on-functions/studio/part-three-number-sorting-easy-way.js new file mode 100644 index 0000000000..386cde1da8 --- /dev/null +++ b/more-on-functions/studio/part-three-number-sorting-easy-way.js @@ -0,0 +1,8 @@ +//Sample arrays for testing: +let nums1 = [5, 10, 2, 42]; +let nums2 = [-2, 0, -10, -44, 5, 3, 0, 3]; +let nums3 = [200, 5, 4, 10, 8, 5, -3.3, 4.4, 0]; + +//Sort each array in ascending order. + +//Sort each array in decending order. diff --git a/more-on-functions/studio/part-two-create-sorted-array.js b/more-on-functions/studio/part-two-create-sorted-array.js new file mode 100644 index 0000000000..bc362a3101 --- /dev/null +++ b/more-on-functions/studio/part-two-create-sorted-array.js @@ -0,0 +1,29 @@ +function findMinValue(arr){ + let min = arr[0]; + for (i = 0; i < arr.length; i++){ + if (arr[i] < min){ + min = arr[i]; + } + } + return min; +} + +//Create a function with an array of numbers as its parameter. This function will return a new array with the numbers sorted from least to greatest value. + +/*Within the function: +1) Define a new, empty array to hold the final sorted numbers. +2) Use the findMinValue function to find the minimum value in the old array. +3) Add the minimum value to the new array, and remove the minimum value from the old array. +4) Repeat parts b & c until the old array is empty. +5) Return the new sorted array. +6) Be sure to print the results in order to verify your code.*/ + +//Your function here... + +/* BONUS MISSION: Refactor your sorting function to use recursion below: + */ + +//Sample arrays for testing: +let nums1 = [5, 10, 2, 42]; +let nums2 = [-2, 0, -10, -44, 5, 3, 0, 3]; +let nums3 = [200, 5, 4, 10, 8, 5, -3.3, 4.4, 0]; From 38bbb4416382e7dde52bbeed8934335b3055c563 Mon Sep 17 00:00:00 2001 From: Sally Steuterman Date: Tue, 5 Sep 2023 14:38:50 -0500 Subject: [PATCH 17/46] Migrating starter code for Chapter 12 --- .../chapter-examples/ForInLoop.js | 9 +++ .../chapter-examples/KindnessSelection.js | 17 ++++++ objects-and-math/exercises/ObjectExercises.js | 22 +++++++ objects-and-math/studio/ObjectsStudio01.js | 55 ++++++++++++++++++ objects-and-math/studio/ObjectsStudio02.js | 58 +++++++++++++++++++ objects-and-math/studio/ObjectsStudio03.js | 54 +++++++++++++++++ 6 files changed, 215 insertions(+) create mode 100644 objects-and-math/chapter-examples/ForInLoop.js create mode 100644 objects-and-math/chapter-examples/KindnessSelection.js create mode 100644 objects-and-math/exercises/ObjectExercises.js create mode 100644 objects-and-math/studio/ObjectsStudio01.js create mode 100644 objects-and-math/studio/ObjectsStudio02.js create mode 100644 objects-and-math/studio/ObjectsStudio03.js diff --git a/objects-and-math/chapter-examples/ForInLoop.js b/objects-and-math/chapter-examples/ForInLoop.js new file mode 100644 index 0000000000..f643903df1 --- /dev/null +++ b/objects-and-math/chapter-examples/ForInLoop.js @@ -0,0 +1,9 @@ +let tortoiseOne = { + species: "Galapagos Tortoise", + name: "Pete", + weight: 919, + age: 85, + diet: ["pumpkins", "lettuce", "cabbage"] +}; + +// Using a for..in loop, iterate through each property in the tortoiseOne object and print the value to the console. \ No newline at end of file diff --git a/objects-and-math/chapter-examples/KindnessSelection.js b/objects-and-math/chapter-examples/KindnessSelection.js new file mode 100644 index 0000000000..d920d345da --- /dev/null +++ b/objects-and-math/chapter-examples/KindnessSelection.js @@ -0,0 +1,17 @@ +function randomSelection(arr){ + let index = Math.floor(Math.random()*arr.length); + return arr[index]; + } + + let happiness = ['Hope', 'Joy', 'Peace', 'Love', 'Kindness', 'Puppies', 'Kittens', 'Tortoise']; + + let words = ['Hello', 'World', 'Python', 'JavaScript', 'Rutabaga']; + + for (i=0; i < 8; i++){ + console.log(randomSelection(happiness)); + } + + //Experiment with the code above. Try to: + //a) Print 3 random selections from each array. + //b) Have the code randomly pick one array, and then print 2 random items from it. + //c) Create a new array, then fill it with one random item from words and happiness. Print the new array. \ No newline at end of file diff --git a/objects-and-math/exercises/ObjectExercises.js b/objects-and-math/exercises/ObjectExercises.js new file mode 100644 index 0000000000..03cc68bc3a --- /dev/null +++ b/objects-and-math/exercises/ObjectExercises.js @@ -0,0 +1,22 @@ +let superChimpOne = { + name: "Chad", + species: "Chimpanzee", + mass: 9, + age: 6 +}; + +let salamander = { + name: "Lacey", + species: "Axolotl Salamander", + mass: 0.1, + age: 5 +}; + + +// After you have created the other object literals, add the astronautID property to each one. + +// Create an array to hold the animal objects. + +// Print out the relevant information about each animal. + +// Start an animal race! \ No newline at end of file diff --git a/objects-and-math/studio/ObjectsStudio01.js b/objects-and-math/studio/ObjectsStudio01.js new file mode 100644 index 0000000000..98dd0cd471 --- /dev/null +++ b/objects-and-math/studio/ObjectsStudio01.js @@ -0,0 +1,55 @@ +// Code your selectRandomEntry function here: + + +// Code your buildCrewArray function here: + + +let idNumbers = [291, 414, 503, 599, 796, 890]; + +// Here are the candidates and the 'animals' array: +let candidateA = { + 'name':'Gordon Shumway', + 'species':'alf', + 'mass':90, + 'o2Used':function(hrs){return 0.035*hrs}, + 'astronautID':414 +}; +let candidateB = { + 'name':'Lassie', + 'species':'dog', + 'mass':19.1, + 'o2Used':function(hrs){return 0.030*hrs}, + 'astronautID':503 +}; +let candidateC = { + 'name':'Jonsey', + 'species':'cat', + 'mass':3.6, + 'o2Used':function(hrs){return 0.022*hrs}, + 'astronautID':796 +}; +let candidateD = { + 'name':'Paddington', + 'species':'bear', + 'mass':31.8, + 'o2Used':function(hrs){return 0.047*hrs}, + 'astronautID':291 +}; +let candidateE = { + 'name':'Pete', + 'species':'tortoise', + 'mass':417, + 'o2Used':function(hrs){return 0.010*hrs}, + 'astronautID':599 +}; +let candidateF = { + 'name':'Hugs', + 'species':'ball python', + 'mass':2.3, + 'o2Used':function(hrs){return 0.018*hrs}, + 'astronautID':890 +}; + +let animals = [candidateA,candidateB,candidateC,candidateD,candidateE,candidateF]; + +// Code your template literal and console.log statements: diff --git a/objects-and-math/studio/ObjectsStudio02.js b/objects-and-math/studio/ObjectsStudio02.js new file mode 100644 index 0000000000..987bd46bfe --- /dev/null +++ b/objects-and-math/studio/ObjectsStudio02.js @@ -0,0 +1,58 @@ +// Code your orbitCircumference function here: + + +// Code your missionDuration function here: + + +// Copy/paste your selectRandomEntry function here: + + +// Code your oxygenExpended function here: + + +// Candidate data & crew array. +let candidateA = { + 'name':'Gordon Shumway', + 'species':'alf', + 'mass':90, + 'o2Used':function(hrs){return 0.035*hrs}, + 'astronautID':414 + }; + let candidateB = { + 'name':'Lassie', + 'species':'dog', + 'mass':19.1, + 'o2Used':function(hrs){return 0.030*hrs}, + 'astronautID':503 + }; + let candidateC = { + 'name':'Jonsey', + 'species':'cat', + 'mass':3.6, + 'o2Used':function(hrs){return 0.022*hrs}, + 'astronautID':796 + }; + let candidateD = { + 'name':'Paddington', + 'species':'bear', + 'mass':31.8, + 'o2Used':function(hrs){return 0.047*hrs}, + 'astronautID':291 + }; + let candidateE = { + 'name':'Pete', + 'species':'tortoise', + 'mass':417, + 'o2Used':function(hrs){return 0.010*hrs}, + 'astronautID':599 + }; + let candidateF = { + 'name':'Hugs', + 'species':'ball python', + 'mass':2.3, + 'o2Used':function(hrs){return 0.018*hrs}, + 'astronautID':890 + }; + + let crew = [candidateA,candidateC,candidateE]; + \ No newline at end of file diff --git a/objects-and-math/studio/ObjectsStudio03.js b/objects-and-math/studio/ObjectsStudio03.js new file mode 100644 index 0000000000..296b74d873 --- /dev/null +++ b/objects-and-math/studio/ObjectsStudio03.js @@ -0,0 +1,54 @@ +// Code your crewMass function here: + + +// Code your fuelRequired function here: + + +// The pre-selected crew is in the array at the end of this file. +// Feel free to add, remove, or switch crew members as you see fit. + +let candidateA = { + 'name':'Gordon Shumway', + 'species':'alf', + 'mass':90, + 'o2Used':function(hrs){return 0.035*hrs}, + 'astronautID':414 + }; + let candidateB = { + 'name':'Lassie', + 'species':'dog', + 'mass':19.1, + 'o2Used':function(hrs){return 0.030*hrs}, + 'astronautID':503 + }; + let candidateC = { + 'name':'Jonsey', + 'species':'cat', + 'mass':3.6, + 'o2Used':function(hrs){return 0.022*hrs}, + 'astronautID':796 + }; + let candidateD = { + 'name':'Paddington', + 'species':'bear', + 'mass':31.8, + 'o2Used':function(hrs){return 0.047*hrs}, + 'astronautID':291 + }; + let candidateE = { + 'name':'Pete', + 'species':'tortoise', + 'mass':417, + 'o2Used':function(hrs){return 0.010*hrs}, + 'astronautID':599 + }; + let candidateF = { + 'name':'Hugs', + 'species':'ball python', + 'mass':2.3, + 'o2Used':function(hrs){return 0.018*hrs}, + 'astronautID':890 + }; + + let crew = [candidateB,candidateD,candidateF]; + \ No newline at end of file From 0912c89e96c6b2152d340dd4e1c368ba3eeacb5b Mon Sep 17 00:00:00 2001 From: Sally Steuterman Date: Mon, 11 Sep 2023 16:23:58 -0500 Subject: [PATCH 18/46] Adding starter code files for unit testing chapter --- .../chapter-examples/hello-jest/hello.js | 8 +++++++ .../chapter-examples/hello-jest/package.json | 17 +++++++++++++++ .../hello-jest/tests/hello.test.js | 13 ++++++++++++ .../reverse-example/package.json | 17 +++++++++++++++ .../reverse-example/reverse.js | 7 +++++++ .../reverse-example/tests/reverse.test.js | 21 +++++++++++++++++++ .../transmission-processor/package.json | 17 +++++++++++++++ .../tests/processor.test.js | 5 +++++ unit-testing/exercises/RPS.js | 20 ++++++++++++++++++ unit-testing/exercises/checkFive.js | 11 ++++++++++ unit-testing/exercises/package.json | 17 +++++++++++++++ unit-testing/exercises/tests/RPS.test.js | 0 .../exercises/tests/checkFive.test.js | 0 unit-testing/studio/index.js | 7 +++++++ unit-testing/studio/package.json | 17 +++++++++++++++ unit-testing/studio/tests/launchcode.test.js | 8 +++++++ 16 files changed, 185 insertions(+) create mode 100644 unit-testing/chapter-examples/hello-jest/hello.js create mode 100644 unit-testing/chapter-examples/hello-jest/package.json create mode 100644 unit-testing/chapter-examples/hello-jest/tests/hello.test.js create mode 100644 unit-testing/chapter-examples/reverse-example/package.json create mode 100644 unit-testing/chapter-examples/reverse-example/reverse.js create mode 100644 unit-testing/chapter-examples/reverse-example/tests/reverse.test.js create mode 100644 unit-testing/chapter-examples/transmission-processor/package.json create mode 100644 unit-testing/chapter-examples/transmission-processor/tests/processor.test.js create mode 100644 unit-testing/exercises/RPS.js create mode 100644 unit-testing/exercises/checkFive.js create mode 100644 unit-testing/exercises/package.json create mode 100644 unit-testing/exercises/tests/RPS.test.js create mode 100644 unit-testing/exercises/tests/checkFive.test.js create mode 100644 unit-testing/studio/index.js create mode 100644 unit-testing/studio/package.json create mode 100644 unit-testing/studio/tests/launchcode.test.js diff --git a/unit-testing/chapter-examples/hello-jest/hello.js b/unit-testing/chapter-examples/hello-jest/hello.js new file mode 100644 index 0000000000..f0b150d4b4 --- /dev/null +++ b/unit-testing/chapter-examples/hello-jest/hello.js @@ -0,0 +1,8 @@ +function hello(name) { + if (name === undefined) + name = "World"; + + return "Hello, " + name + "!"; +} + +module.exports = hello; \ No newline at end of file diff --git a/unit-testing/chapter-examples/hello-jest/package.json b/unit-testing/chapter-examples/hello-jest/package.json new file mode 100644 index 0000000000..568f2ad084 --- /dev/null +++ b/unit-testing/chapter-examples/hello-jest/package.json @@ -0,0 +1,17 @@ +{ + "name": "unit-testing", + "version": "1.0.0", + "description": "", + "main": "hello.js", + "scripts": { + "test": "jest" + }, + "author": "", + "license": "ISC", + "dependencies": { + "readline-sync": "^1.4.10" + }, + "devDependencies": { + "jest": "^29.6.4" + } + } \ No newline at end of file diff --git a/unit-testing/chapter-examples/hello-jest/tests/hello.test.js b/unit-testing/chapter-examples/hello-jest/tests/hello.test.js new file mode 100644 index 0000000000..17d3f500ca --- /dev/null +++ b/unit-testing/chapter-examples/hello-jest/tests/hello.test.js @@ -0,0 +1,13 @@ +const hello = require('../hello.js'); + +describe("hello world test", function(){ + + test("should return a custom message when name is specified", function(){ + expect(hello("Jest")).toBe("Hello, Jest!"); + }); + + it("should return a general greeting when name is not specified", function(){ + expect(hello()).toBe("Hello, World!"); + }); + +}); \ No newline at end of file diff --git a/unit-testing/chapter-examples/reverse-example/package.json b/unit-testing/chapter-examples/reverse-example/package.json new file mode 100644 index 0000000000..03d961386b --- /dev/null +++ b/unit-testing/chapter-examples/reverse-example/package.json @@ -0,0 +1,17 @@ +{ + "name": "unit-testing", + "version": "1.0.0", + "description": "", + "main": "reverse.js", + "scripts": { + "test": "jest" + }, + "author": "", + "license": "ISC", + "dependencies": { + "readline-sync": "^1.4.10" + }, + "devDependencies": { + "jest": "^29.6.4" + } + } \ No newline at end of file diff --git a/unit-testing/chapter-examples/reverse-example/reverse.js b/unit-testing/chapter-examples/reverse-example/reverse.js new file mode 100644 index 0000000000..157c2e134b --- /dev/null +++ b/unit-testing/chapter-examples/reverse-example/reverse.js @@ -0,0 +1,7 @@ +function reverse(str) { + let lettersArray = str.split(''); + let reversedLettersArray = lettersArray.reverse(); + return reversedLettersArray.join(''); +} + +module.exports = reverse; \ No newline at end of file diff --git a/unit-testing/chapter-examples/reverse-example/tests/reverse.test.js b/unit-testing/chapter-examples/reverse-example/tests/reverse.test.js new file mode 100644 index 0000000000..f04f29d761 --- /dev/null +++ b/unit-testing/chapter-examples/reverse-example/tests/reverse.test.js @@ -0,0 +1,21 @@ +const reverse = require('../reverse.js'); + +describe("reverse", function(){ + + test("should not change a single character", function(){ + expect(reverse("a")).toBe("a"); + }); + + test("should handle the empty string", function(){ + expect(reverse("")).toBe(""); + }); + + test("should reverse a short string", function(){ + expect(reverse("dog")).toBe("god"); + }); + + test("should reverse a long string", function(){ + expect(reverse("LaunchCode")).toBe("edoChcnuaL"); + }); + +}); \ No newline at end of file diff --git a/unit-testing/chapter-examples/transmission-processor/package.json b/unit-testing/chapter-examples/transmission-processor/package.json new file mode 100644 index 0000000000..7776032cc1 --- /dev/null +++ b/unit-testing/chapter-examples/transmission-processor/package.json @@ -0,0 +1,17 @@ +{ + "name": "unit-testing", + "version": "1.0.0", + "description": "", + "main": "processor.js", + "scripts": { + "test": "jest" + }, + "author": "", + "license": "ISC", + "dependencies": { + "readline-sync": "^1.4.10" + }, + "devDependencies": { + "jest": "^29.6.4" + } + } \ No newline at end of file diff --git a/unit-testing/chapter-examples/transmission-processor/tests/processor.test.js b/unit-testing/chapter-examples/transmission-processor/tests/processor.test.js new file mode 100644 index 0000000000..1068db895f --- /dev/null +++ b/unit-testing/chapter-examples/transmission-processor/tests/processor.test.js @@ -0,0 +1,5 @@ +describe("transmission processor", function() { + + // TODO: put tests here + + }); \ No newline at end of file diff --git a/unit-testing/exercises/RPS.js b/unit-testing/exercises/RPS.js new file mode 100644 index 0000000000..6c1b3bad8d --- /dev/null +++ b/unit-testing/exercises/RPS.js @@ -0,0 +1,20 @@ +function whoWon(player1,player2){ + + if (player1 === player2){ + return 'TIE!'; + } + + if (player1 === 'rock' && player2 === 'paper'){ + return 'Player 2 wins!'; + } + + if (player1 === 'paper' && player2 === 'scissors'){ + return 'Player 2 wins!'; + } + + if (player1 === 'scissors' && player2 === 'rock '){ + return 'Player 2 wins!'; + } + + return 'Player 1 wins!'; + } \ No newline at end of file diff --git a/unit-testing/exercises/checkFive.js b/unit-testing/exercises/checkFive.js new file mode 100644 index 0000000000..315da7b46b --- /dev/null +++ b/unit-testing/exercises/checkFive.js @@ -0,0 +1,11 @@ +function checkFive(num){ + let result = ''; + if (num < 5){ + result = num + " is less than 5."; + } else if (num === 5){ + result = num + " is equal to 5."; + } else { + result = num + " is greater than 5."; + } + return result; + } \ No newline at end of file diff --git a/unit-testing/exercises/package.json b/unit-testing/exercises/package.json new file mode 100644 index 0000000000..0585133d7f --- /dev/null +++ b/unit-testing/exercises/package.json @@ -0,0 +1,17 @@ +{ + "name": "unit-testing", + "version": "1.0.0", + "description": "", + "main": "checkFive.js", + "scripts": { + "test": "jest" + }, + "author": "", + "license": "ISC", + "dependencies": { + "readline-sync": "^1.4.10" + }, + "devDependencies": { + "jest": "^29.6.4" + } + } \ No newline at end of file diff --git a/unit-testing/exercises/tests/RPS.test.js b/unit-testing/exercises/tests/RPS.test.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/unit-testing/exercises/tests/checkFive.test.js b/unit-testing/exercises/tests/checkFive.test.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/unit-testing/studio/index.js b/unit-testing/studio/index.js new file mode 100644 index 0000000000..2ba56cb9bd --- /dev/null +++ b/unit-testing/studio/index.js @@ -0,0 +1,7 @@ + +let launchcode = { + +} + +module.exports = launchcode; + diff --git a/unit-testing/studio/package.json b/unit-testing/studio/package.json new file mode 100644 index 0000000000..18a24da735 --- /dev/null +++ b/unit-testing/studio/package.json @@ -0,0 +1,17 @@ +{ + "name": "unit-testing", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "jest" + }, + "author": "", + "license": "ISC", + "dependencies": { + "readline-sync": "^1.4.10" + }, + "devDependencies": { + "jest": "^29.6.4" + } + } \ No newline at end of file diff --git a/unit-testing/studio/tests/launchcode.test.js b/unit-testing/studio/tests/launchcode.test.js new file mode 100644 index 0000000000..f535305e3b --- /dev/null +++ b/unit-testing/studio/tests/launchcode.test.js @@ -0,0 +1,8 @@ +// launchcode.test.js code: +const launchcode = require('../index.js'); + +describe("Testing launchcode", function(){ + + // Write your unit tests here! + +}); \ No newline at end of file From 824faecbf4dc082ec92bbb271ae869fdf2a06210 Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Tue, 12 Sep 2023 11:50:29 -0500 Subject: [PATCH 19/46] added modules section, starter code from exporting-modules walkthrough --- modules/exporting-modules/index.js | 1 + modules/exporting-modules/practiceExports.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 modules/exporting-modules/index.js create mode 100644 modules/exporting-modules/practiceExports.js diff --git a/modules/exporting-modules/index.js b/modules/exporting-modules/index.js new file mode 100644 index 0000000000..67cae34eff --- /dev/null +++ b/modules/exporting-modules/index.js @@ -0,0 +1 @@ +// Import the modules exported from practiceExports.js below: diff --git a/modules/exporting-modules/practiceExports.js b/modules/exporting-modules/practiceExports.js new file mode 100644 index 0000000000..427cbcc666 --- /dev/null +++ b/modules/exporting-modules/practiceExports.js @@ -0,0 +1,16 @@ +function isPalindrome(str){ + return str === str.split('').reverse().join(''); +} + +function evenOrOdd(num){ + if (num%2===0){ + return "Even"; + } else { + return "Odd"; + } +} + +function randomArrayElement(arr){ + let index = Math.floor(Math.random()*arr.length); + return arr[index]; +} From fbcd92a20ed53deb3412d9892bfb97bc0ee39819 Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Tue, 12 Sep 2023 13:04:25 -0500 Subject: [PATCH 20/46] added starter code for modules exercises --- modules/exercises/display.js | 36 ++++++++++++++++++++++++++++ modules/exercises/index.js | 39 +++++++++++++++++++++++++++++++ modules/exercises/randomSelect.js | 5 ++++ 3 files changed, 80 insertions(+) create mode 100644 modules/exercises/display.js create mode 100644 modules/exercises/index.js create mode 100644 modules/exercises/randomSelect.js diff --git a/modules/exercises/display.js b/modules/exercises/display.js new file mode 100644 index 0000000000..6bd5f81248 --- /dev/null +++ b/modules/exercises/display.js @@ -0,0 +1,36 @@ +//TODO: Export ONLY the printAll function. + +function printAll(names, tests, scores){ + let header = 'Name'; + let row = ''; + + for (let i = 0; i Date: Tue, 12 Sep 2023 13:21:29 -0500 Subject: [PATCH 21/46] added ScoreCalcs directory and package.json --- modules/exercises/ScoreCalcs/averages.js | 19 +++++++++++++++++++ modules/exercises/package.json | 14 ++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 modules/exercises/ScoreCalcs/averages.js create mode 100644 modules/exercises/package.json diff --git a/modules/exercises/ScoreCalcs/averages.js b/modules/exercises/ScoreCalcs/averages.js new file mode 100644 index 0000000000..a109b6cfb7 --- /dev/null +++ b/modules/exercises/ScoreCalcs/averages.js @@ -0,0 +1,19 @@ +function averageForStudent(nameIndex,scores){ + let sum = 0; + for (let i=0; i Date: Wed, 13 Sep 2023 15:36:53 -0500 Subject: [PATCH 22/46] Update DebuggingRuntimeErrors2.js --- .../exercises/DebuggingRuntimeErrors2.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/errors-and-debugging/exercises/DebuggingRuntimeErrors2.js b/errors-and-debugging/exercises/DebuggingRuntimeErrors2.js index e69de29bb2..a656080d25 100644 --- a/errors-and-debugging/exercises/DebuggingRuntimeErrors2.js +++ b/errors-and-debugging/exercises/DebuggingRuntimeErrors2.js @@ -0,0 +1,21 @@ +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."); +} From 1f936ce3e5718c4461f4321adb6a5c3152c30d52 Mon Sep 17 00:00:00 2001 From: Sally Steuterman Date: Wed, 13 Sep 2023 18:32:55 -0500 Subject: [PATCH 23/46] Switched out palindrome for reverse --- .../package.json | 2 +- .../palindrome-example/palindrome.js | 9 ++++++++ .../reverse-example/reverse.js | 7 ------- .../reverse-example/tests/reverse.test.js | 21 ------------------- 4 files changed, 10 insertions(+), 29 deletions(-) rename unit-testing/chapter-examples/{reverse-example => palindrome-example}/package.json (90%) create mode 100644 unit-testing/chapter-examples/palindrome-example/palindrome.js delete mode 100644 unit-testing/chapter-examples/reverse-example/reverse.js delete mode 100644 unit-testing/chapter-examples/reverse-example/tests/reverse.test.js diff --git a/unit-testing/chapter-examples/reverse-example/package.json b/unit-testing/chapter-examples/palindrome-example/package.json similarity index 90% rename from unit-testing/chapter-examples/reverse-example/package.json rename to unit-testing/chapter-examples/palindrome-example/package.json index 03d961386b..554413f472 100644 --- a/unit-testing/chapter-examples/reverse-example/package.json +++ b/unit-testing/chapter-examples/palindrome-example/package.json @@ -2,7 +2,7 @@ "name": "unit-testing", "version": "1.0.0", "description": "", - "main": "reverse.js", + "main": "palindrome.js", "scripts": { "test": "jest" }, diff --git a/unit-testing/chapter-examples/palindrome-example/palindrome.js b/unit-testing/chapter-examples/palindrome-example/palindrome.js new file mode 100644 index 0000000000..f53f3d1b3c --- /dev/null +++ b/unit-testing/chapter-examples/palindrome-example/palindrome.js @@ -0,0 +1,9 @@ +function reverse(str) { + return str.split('').reverse().join(''); + } + + function isPalindrome(str) { + return reverse(str) === str; + } + + module.exports = isPalindrome; \ No newline at end of file diff --git a/unit-testing/chapter-examples/reverse-example/reverse.js b/unit-testing/chapter-examples/reverse-example/reverse.js deleted file mode 100644 index 157c2e134b..0000000000 --- a/unit-testing/chapter-examples/reverse-example/reverse.js +++ /dev/null @@ -1,7 +0,0 @@ -function reverse(str) { - let lettersArray = str.split(''); - let reversedLettersArray = lettersArray.reverse(); - return reversedLettersArray.join(''); -} - -module.exports = reverse; \ No newline at end of file diff --git a/unit-testing/chapter-examples/reverse-example/tests/reverse.test.js b/unit-testing/chapter-examples/reverse-example/tests/reverse.test.js deleted file mode 100644 index f04f29d761..0000000000 --- a/unit-testing/chapter-examples/reverse-example/tests/reverse.test.js +++ /dev/null @@ -1,21 +0,0 @@ -const reverse = require('../reverse.js'); - -describe("reverse", function(){ - - test("should not change a single character", function(){ - expect(reverse("a")).toBe("a"); - }); - - test("should handle the empty string", function(){ - expect(reverse("")).toBe(""); - }); - - test("should reverse a short string", function(){ - expect(reverse("dog")).toBe("god"); - }); - - test("should reverse a long string", function(){ - expect(reverse("LaunchCode")).toBe("edoChcnuaL"); - }); - -}); \ No newline at end of file From 6d046f4b144d3d28637b75527a58861f58813ee3 Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Thu, 14 Sep 2023 11:31:12 -0500 Subject: [PATCH 24/46] added chapter examples for scope --- scope/chapter-examples/block-local-scope.js | 6 ++++++ scope/chapter-examples/variable-shadowing.js | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 scope/chapter-examples/block-local-scope.js create mode 100644 scope/chapter-examples/variable-shadowing.js diff --git a/scope/chapter-examples/block-local-scope.js b/scope/chapter-examples/block-local-scope.js new file mode 100644 index 0000000000..f245b58602 --- /dev/null +++ b/scope/chapter-examples/block-local-scope.js @@ -0,0 +1,6 @@ +function myFunction() { + let i = 10; + return 10 + i; +} + +console.log(i); diff --git a/scope/chapter-examples/variable-shadowing.js b/scope/chapter-examples/variable-shadowing.js new file mode 100644 index 0000000000..cdfcb165ea --- /dev/null +++ b/scope/chapter-examples/variable-shadowing.js @@ -0,0 +1,18 @@ +const input = require('readline-sync'); + +function hello(name) { + console.log('Hello,', name); + name = 'Ruth'; + return doubleName(name); +} + +function doubleName(name){ + console.log(name+name); + return name+name; +} + +let name = input.question("Please enter your name: "); + +hello(name); +doubleName(name); +console.log(name); From 4623be8b19149d7c7df2db73b227b37945d02853 Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Mon, 18 Sep 2023 11:22:58 -0500 Subject: [PATCH 25/46] exceptions exercises and chapter examples --- .../chapter-examples/finally/finally.js | 14 +++++++++++ .../chapter-examples/finally/package.json | 15 ++++++++++++ .../chapter-examples/throw-default-error.js | 1 + .../chapter-examples/try-catch/package.json | 15 ++++++++++++ .../chapter-examples/try-catch/try-catch.js | 13 ++++++++++ exceptions/exercises/divide.js | 7 ++++++ exceptions/exercises/test-student-labs.js | 24 +++++++++++++++++++ 7 files changed, 89 insertions(+) create mode 100644 exceptions/chapter-examples/finally/finally.js create mode 100644 exceptions/chapter-examples/finally/package.json create mode 100644 exceptions/chapter-examples/throw-default-error.js create mode 100644 exceptions/chapter-examples/try-catch/package.json create mode 100644 exceptions/chapter-examples/try-catch/try-catch.js create mode 100644 exceptions/exercises/divide.js create mode 100644 exceptions/exercises/test-student-labs.js diff --git a/exceptions/chapter-examples/finally/finally.js b/exceptions/chapter-examples/finally/finally.js new file mode 100644 index 0000000000..33c9fe2272 --- /dev/null +++ b/exceptions/chapter-examples/finally/finally.js @@ -0,0 +1,14 @@ +const input = require('readline-sync'); + +let animals = [{name: 'cat'}, {name: 'dog'}]; +let index = Number(input.question("Enter index of animal:")); + +try { + console.log('animal at index:', animals[index].name); +} catch(TypeError) { + console.log("We caught a TypeError, but our program continues to run!"); +} finally { + console.log("You tried to access an animal at index:", index); +} + +console.log("the code goes on..."); diff --git a/exceptions/chapter-examples/finally/package.json b/exceptions/chapter-examples/finally/package.json new file mode 100644 index 0000000000..c447dfacce --- /dev/null +++ b/exceptions/chapter-examples/finally/package.json @@ -0,0 +1,15 @@ +{ + "name": "control-flow-type-error-finally", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "readline-sync": "^1.4.10" + } +} diff --git a/exceptions/chapter-examples/throw-default-error.js b/exceptions/chapter-examples/throw-default-error.js new file mode 100644 index 0000000000..7c01c6b9ad --- /dev/null +++ b/exceptions/chapter-examples/throw-default-error.js @@ -0,0 +1 @@ +throw Error('You cannot divide by zero!'); diff --git a/exceptions/chapter-examples/try-catch/package.json b/exceptions/chapter-examples/try-catch/package.json new file mode 100644 index 0000000000..d805cc4cc0 --- /dev/null +++ b/exceptions/chapter-examples/try-catch/package.json @@ -0,0 +1,15 @@ +{ + "name": "control-flow-type-error", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "readline-sync": "^1.4.10" + } +} diff --git a/exceptions/chapter-examples/try-catch/try-catch.js b/exceptions/chapter-examples/try-catch/try-catch.js new file mode 100644 index 0000000000..15b0192f85 --- /dev/null +++ b/exceptions/chapter-examples/try-catch/try-catch.js @@ -0,0 +1,13 @@ +const input = require('readline-sync'); + +let animals = [{name: 'cat'}, {name: 'dog'}]; +let index = Number(input.question("Enter index of animal:")); + +try { + console.log('animal at index:', animals[index].name); +} catch(TypeError) { + console.log("We caught a TypeError, but our program continues to run!"); + console.log("You tried to access an animal at index:", index); +} + +console.log("the code goes on..."); diff --git a/exceptions/exercises/divide.js b/exceptions/exercises/divide.js new file mode 100644 index 0000000000..06fc889862 --- /dev/null +++ b/exceptions/exercises/divide.js @@ -0,0 +1,7 @@ +// Write a function called 'divide' that takes two parameters: a numerator and a denominator. + +// Your function should return the result of numerator / denominator. + +// However, if the denominator is zero you should throw the error, "Attempted to divide by zero." + +// Code your divide function here: diff --git a/exceptions/exercises/test-student-labs.js b/exceptions/exercises/test-student-labs.js new file mode 100644 index 0000000000..cfe5bfe175 --- /dev/null +++ b/exceptions/exercises/test-student-labs.js @@ -0,0 +1,24 @@ +function gradeLabs(labs) { + 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}`); + } +} + +let studentLabs = [ + { + student: 'Carly', + runLab: function (num) { + return Math.pow(num, num); + } + }, + { + student: 'Erica', + runLab: function (num) { + return num * num; + } + } +]; + +gradeLabs(studentLabs); From 23b55bcb6bf3e20aedc22486f5282487e1eb9c5b Mon Sep 17 00:00:00 2001 From: Sally Steuterman Date: Tue, 19 Sep 2023 11:41:24 -0500 Subject: [PATCH 26/46] Setting up starter code for classes chapter --- classes/chapter-examples/ClassExamples01.js | 21 ++++++++++++++ classes/chapter-examples/ClassExamples02.js | 17 +++++++++++ classes/chapter-examples/ClassMethods.js | 32 +++++++++++++++++++++ classes/chapter-examples/Inheritance.js | 23 +++++++++++++++ classes/exercises/ClassExercises.js | 10 +++++++ classes/studio/ClassStudio.js | 9 ++++++ 6 files changed, 112 insertions(+) create mode 100644 classes/chapter-examples/ClassExamples01.js create mode 100644 classes/chapter-examples/ClassExamples02.js create mode 100644 classes/chapter-examples/ClassMethods.js create mode 100644 classes/chapter-examples/Inheritance.js create mode 100644 classes/exercises/ClassExercises.js create mode 100644 classes/studio/ClassStudio.js diff --git a/classes/chapter-examples/ClassExamples01.js b/classes/chapter-examples/ClassExamples01.js new file mode 100644 index 0000000000..84d2b87dc9 --- /dev/null +++ b/classes/chapter-examples/ClassExamples01.js @@ -0,0 +1,21 @@ +//Try adding new properties inside constructor. +class Astronaut { + constructor(name, age, mass){ + this.name = name; + this.age = age; + this.mass = mass; + } +} + +let fox = new Astronaut('Fox', 7, 12); + +console.log(fox); +console.log(fox.age, fox.color); + +fox.age = 9; +fox.color = 'red'; + +console.log(fox); +console.log(fox.age, fox.color); + +//Try modifying or adding properties below. \ No newline at end of file diff --git a/classes/chapter-examples/ClassExamples02.js b/classes/chapter-examples/ClassExamples02.js new file mode 100644 index 0000000000..5f7ee4e0fd --- /dev/null +++ b/classes/chapter-examples/ClassExamples02.js @@ -0,0 +1,17 @@ +// Use terminal commands to see what happens when we call Astronaut but do not pass in 3 arguments. + +// Next, set default values for 1 or more of the parameters in constructor. + +class Astronaut { + constructor(name, age, mass){ + this.name = name; + this.age = age; + this.mass = mass; + } +} + +let tortoise = new Astronaut('Speedy', 120); + +console.log(tortoise.name, tortoise.age, tortoise.mass); + +// What happens if we call Astronaut and pass in MORE than 3 arguments? TRY IT! \ No newline at end of file diff --git a/classes/chapter-examples/ClassMethods.js b/classes/chapter-examples/ClassMethods.js new file mode 100644 index 0000000000..b98b8b5bf3 --- /dev/null +++ b/classes/chapter-examples/ClassMethods.js @@ -0,0 +1,32 @@ +// Here we assign the method inside the constructor +class AstronautI { + constructor(name, age, mass){ + this.name = name; + this.age = age; + this.mass = mass; + this.reportStats = function() { + let stats = `${this.name} is ${this.age} years old and has a mass of ${this.mass} kg.`; + return stats; + } + } + } + + // Here we assign the method outside of the constructor + class AstronautO { + constructor(name, age, mass){ + this.name = name; + this.age = age; + this.mass = mass; + } + + reportStats() { + let stats = `${this.name} is ${this.age} years old and has a mass of ${this.mass} kg.`; + return stats; + } + } + + let fox = new AstronautI('Fox', 7, 12); + let hippo = new AstronautO('Hippo', 25, 1000); + + console.log(fox); + console.log(hippo); \ No newline at end of file diff --git a/classes/chapter-examples/Inheritance.js b/classes/chapter-examples/Inheritance.js new file mode 100644 index 0000000000..0bc4dc88a1 --- /dev/null +++ b/classes/chapter-examples/Inheritance.js @@ -0,0 +1,23 @@ +class Felidae { + constructor() { + this.claws = "retractable"; + } +} + +class Panthera extends Felidae { + constructor() { + super(); + this.roar = "loud"; + } +} + +class Tiger extends Panthera { + constructor() { + super(); + this.hasStripes = "true"; + } +} + +let tigger = new Tiger(); + +console.log(tigger); \ No newline at end of file diff --git a/classes/exercises/ClassExercises.js b/classes/exercises/ClassExercises.js new file mode 100644 index 0000000000..91b9ee5b9d --- /dev/null +++ b/classes/exercises/ClassExercises.js @@ -0,0 +1,10 @@ +// Define your Book class here: + + +// Define your Manual and Novel classes here: + + +// Declare the objects for exercises 2 and 3 here: + + +// Code exercises 4 & 5 here: \ No newline at end of file diff --git a/classes/studio/ClassStudio.js b/classes/studio/ClassStudio.js new file mode 100644 index 0000000000..c3a6152140 --- /dev/null +++ b/classes/studio/ClassStudio.js @@ -0,0 +1,9 @@ +//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. + + + +//Add methods for adding scores, averaging scores and determining candidate status as described in the studio activity. + + + +//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 From 21b9f0248f3257e8bca9f861c56a52aafc2fc9c2 Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Tue, 26 Sep 2023 10:11:36 -0500 Subject: [PATCH 27/46] added css directory for exercises --- css/index.html | 22 ++++++++++++++++++++++ css/script.js | 1 + css/styles.css | 1 + 3 files changed, 24 insertions(+) create mode 100644 css/index.html create mode 100644 css/script.js create mode 100644 css/styles.css diff --git a/css/index.html b/css/index.html new file mode 100644 index 0000000000..69f47f9239 --- /dev/null +++ b/css/index.html @@ -0,0 +1,22 @@ + + + + + + CSS Exercises + + + + + +

My Very Cool Web Page

+

Why this Website is Very Cool

+
    +
  1. I made it!
  2. +
  3. This website is colorful!
  4. +
+

Why I love Web Development

+

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/script.js b/css/script.js new file mode 100644 index 0000000000..3bbac89f48 --- /dev/null +++ b/css/script.js @@ -0,0 +1 @@ +// You do not need to do anything with script.js right now! Later, we will learn how to add JavaScript to websites! diff --git a/css/styles.css b/css/styles.css new file mode 100644 index 0000000000..3b88bed453 --- /dev/null +++ b/css/styles.css @@ -0,0 +1 @@ +/* Start adding your styling below! */ From 7ddffa25ad2cab83a8679c237ca3cc437889720c Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Tue, 26 Sep 2023 10:12:11 -0500 Subject: [PATCH 28/46] moved files into exercises folder --- css/{ => exercises}/index.html | 0 css/{ => exercises}/script.js | 0 css/{ => exercises}/styles.css | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename css/{ => exercises}/index.html (100%) rename css/{ => exercises}/script.js (100%) rename css/{ => exercises}/styles.css (100%) diff --git a/css/index.html b/css/exercises/index.html similarity index 100% rename from css/index.html rename to css/exercises/index.html diff --git a/css/script.js b/css/exercises/script.js similarity index 100% rename from css/script.js rename to css/exercises/script.js diff --git a/css/styles.css b/css/exercises/styles.css similarity index 100% rename from css/styles.css rename to css/exercises/styles.css From 1e86510c17c3dcedffa84421812a25929501b0dc Mon Sep 17 00:00:00 2001 From: Sally Steuterman Date: Tue, 26 Sep 2023 13:33:29 -0500 Subject: [PATCH 29/46] Starter code for HTML chapter and new gitignore --- .gitignore | 1 + html/exercises/index.html | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 .gitignore create mode 100644 html/exercises/index.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..496ee2ca6a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store \ No newline at end of file diff --git a/html/exercises/index.html b/html/exercises/index.html new file mode 100644 index 0000000000..80f716a800 --- /dev/null +++ b/html/exercises/index.html @@ -0,0 +1,16 @@ + + + + + + HTML Exercise + + + + + + + + + + \ No newline at end of file From b1426e0e95d806b7be4371d35b43ef962d7cdf34 Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Mon, 2 Oct 2023 10:43:58 -0500 Subject: [PATCH 30/46] added terminal-commands directory for appendices walkthrough --- terminal-commands/launchcode_courses/data_analysis/cities.sql | 0 .../data_analysis/final_project/.empty_file.txt | 0 terminal-commands/launchcode_courses/data_analysis/lakes.json | 0 terminal-commands/launchcode_courses/lc_101/unit_1/about_me.html | 0 terminal-commands/launchcode_courses/lc_101/unit_1/hello_world.js | 0 terminal-commands/launchcode_courses/lc_101/unit_1/styles.css | 0 6 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 terminal-commands/launchcode_courses/data_analysis/cities.sql create mode 100644 terminal-commands/launchcode_courses/data_analysis/final_project/.empty_file.txt create mode 100644 terminal-commands/launchcode_courses/data_analysis/lakes.json create mode 100644 terminal-commands/launchcode_courses/lc_101/unit_1/about_me.html create mode 100644 terminal-commands/launchcode_courses/lc_101/unit_1/hello_world.js create mode 100644 terminal-commands/launchcode_courses/lc_101/unit_1/styles.css diff --git a/terminal-commands/launchcode_courses/data_analysis/cities.sql b/terminal-commands/launchcode_courses/data_analysis/cities.sql new file mode 100644 index 0000000000..e69de29bb2 diff --git a/terminal-commands/launchcode_courses/data_analysis/final_project/.empty_file.txt b/terminal-commands/launchcode_courses/data_analysis/final_project/.empty_file.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/terminal-commands/launchcode_courses/data_analysis/lakes.json b/terminal-commands/launchcode_courses/data_analysis/lakes.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/terminal-commands/launchcode_courses/lc_101/unit_1/about_me.html b/terminal-commands/launchcode_courses/lc_101/unit_1/about_me.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/terminal-commands/launchcode_courses/lc_101/unit_1/hello_world.js b/terminal-commands/launchcode_courses/lc_101/unit_1/hello_world.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/terminal-commands/launchcode_courses/lc_101/unit_1/styles.css b/terminal-commands/launchcode_courses/lc_101/unit_1/styles.css new file mode 100644 index 0000000000..e69de29bb2 From 29099a0c9b27d61ec7eef7ddd98fe4f0fdfcc723 Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Tue, 3 Oct 2023 11:23:01 -0500 Subject: [PATCH 31/46] added dom-and-events directory with exercises --- dom-and-events/exercises/index.html | 14 ++++++++++++++ dom-and-events/exercises/script.js | 10 ++++++++++ dom-and-events/exercises/style.css | 3 +++ 3 files changed, 27 insertions(+) create mode 100644 dom-and-events/exercises/index.html create mode 100644 dom-and-events/exercises/script.js create mode 100644 dom-and-events/exercises/style.css diff --git a/dom-and-events/exercises/index.html b/dom-and-events/exercises/index.html new file mode 100644 index 0000000000..5a4fbd916d --- /dev/null +++ b/dom-and-events/exercises/index.html @@ -0,0 +1,14 @@ + + + + Flight Simulator + + + + +

Flight Simulator

+

The shuttle is on the ground

+ + + + diff --git a/dom-and-events/exercises/script.js b/dom-and-events/exercises/script.js new file mode 100644 index 0000000000..de6b630519 --- /dev/null +++ b/dom-and-events/exercises/script.js @@ -0,0 +1,10 @@ +function init () { + const missionAbort = document.getElementById("abortMission"); + const button = document.getElementById("liftoffButton"); + const paragraph = document.getElementById("statusReport"); + + // Put your code for the exercises here. + +} + +window.addEventListener("load", init); diff --git a/dom-and-events/exercises/style.css b/dom-and-events/exercises/style.css new file mode 100644 index 0000000000..b2d3dc07c3 --- /dev/null +++ b/dom-and-events/exercises/style.css @@ -0,0 +1,3 @@ +h1 { + text-decoration: underline; +} From f2c92eeb2d228b688031ae7152c79ee91bee9f68 Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Tue, 3 Oct 2023 11:27:36 -0500 Subject: [PATCH 32/46] added starter code for studio to dom-and-events --- .../studio/LaunchCode_rocketline_white.png | Bin 0 -> 17232 bytes dom-and-events/studio/index.html | 40 ++++++++++++++++++ dom-and-events/studio/scripts.js | 2 + dom-and-events/studio/styles.css | 30 +++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 dom-and-events/studio/LaunchCode_rocketline_white.png create mode 100644 dom-and-events/studio/index.html create mode 100644 dom-and-events/studio/scripts.js create mode 100644 dom-and-events/studio/styles.css diff --git a/dom-and-events/studio/LaunchCode_rocketline_white.png b/dom-and-events/studio/LaunchCode_rocketline_white.png new file mode 100644 index 0000000000000000000000000000000000000000..07174271f34b51f511ff3a8a7f10e01f5293889a GIT binary patch literal 17232 zcmeIac{r49A2)s>OGtH>Eu!L9DO*CaRc@6#gUXOy*_W|1ma(Kz5qFemY$=40Y%z?b zkSt@#Zj62GgTdJS&TG1#_j!KL@jS=-&+mQz_`UCOjG^;#toC7o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zlk%86V_Ytc0FW;8oq*NUbTBLN*Phi9> z>24D~OibsWfQpG2l_|}jBl$tk@L^?dD2fj7g@LDGPEh>&zuy5>CRxY43vt^Of??r? zzY;(>^UI|M*XR|Ua6!=Hnezp&6X-)fN<|BD&B*P5#GeA%!D zL&Gm2@9x&Nl2fo2rqEVKg7xPl>6%t4jVp;yy%3#qqD%G20L zS6#S9$<6vTGIPH1pzlzafr4frNT4i&l*c%rEw{ux_KH8>!z;}_N5Lq}5M9J{XAi-E{_7wN`+vRy1O4~y|2F4e zuKaWL|4j>3@456up`gbPPp}F7#;p77*5e;`bxHBx9*Qs?+9xd%!1OwI1v&wvbcoI< z{MQva1VC&MGy-#53%>>a80PMuf3eXK{0~$9`{aL4`R8Bso&V#Mf7|&#P5JMW>BQ2f z{PVB>%3tt*;`HD4`>&J#1(N@dz}aqbVjTYcR?Gtyknaiu;#A*?_O(FO7PmgXVeoll zVEYeY{0|b7Ynf*th;at~e*u2U@}G!aS$_lW|93h5kE#DZ6@B6xBS(E`=#%JK8^}U; zi-FGXmmk2f{?Byy1O@@_`Jbr7zrpuUwEqR?|6}#{e>phLiqI$p + + + Flight Simulator + + + + +
+

Flight Simulator

+

Current Flight Status

+

Space shuttle ready for takeoff

+

Shuttle Trajectory

+
+
+
+

Fuel Levels

+

Tank Full

+

Astronaut Chat

+

Houston, we are ready when you are!

+
+
+ +
+
+ + + + +

Space Shuttle Height

+

0

miles +
+
+
+ + + +
+ + \ No newline at end of file diff --git a/dom-and-events/studio/scripts.js b/dom-and-events/studio/scripts.js new file mode 100644 index 0000000000..45c9b3a9d1 --- /dev/null +++ b/dom-and-events/studio/scripts.js @@ -0,0 +1,2 @@ +// Write your JavaScript code here. +// Remember to pay attention to page loading! diff --git a/dom-and-events/studio/styles.css b/dom-and-events/studio/styles.css new file mode 100644 index 0000000000..cc932dd89d --- /dev/null +++ b/dom-and-events/studio/styles.css @@ -0,0 +1,30 @@ +#shuttleBackground { + background-color: green; + display: inline-block; + height: 80%; + width: 40%; + position: relative; +} + +#flightStatus { + color: green; +} + +#flightDisplay { + text-align: center; + height: 400px; + width: 100%; +} + +#spaceShuttleHeight { + display: inline-block; +} + +.center-block { + text-align: center; + display: inline-block; +} + +.centered { + text-align: center; +} \ No newline at end of file From 47364289df9950362da7e77b06ea3748eab39c60 Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Mon, 9 Oct 2023 11:07:17 -0500 Subject: [PATCH 33/46] initial user-input-with-forms content need to add additional chapter examples, exercises, and studio code --- .../chapter-examples/form-post.html | 25 ++++++++++++++++++ .../chapter-examples/form-submission.html | 25 ++++++++++++++++++ .../form-validation/index.html | 26 +++++++++++++++++++ .../form-validation/script.js | 1 + .../form-validation/style.css | 1 + 5 files changed, 78 insertions(+) create mode 100644 user-input-with-forms/chapter-examples/form-post.html create mode 100644 user-input-with-forms/chapter-examples/form-submission.html create mode 100644 user-input-with-forms/chapter-examples/form-validation/index.html create mode 100644 user-input-with-forms/chapter-examples/form-validation/script.js create mode 100644 user-input-with-forms/chapter-examples/form-validation/style.css diff --git a/user-input-with-forms/chapter-examples/form-post.html b/user-input-with-forms/chapter-examples/form-post.html new file mode 100644 index 0000000000..bebc7c21ab --- /dev/null +++ b/user-input-with-forms/chapter-examples/form-post.html @@ -0,0 +1,25 @@ + + + + + Form POST + + + + +
+ + + +
+ + diff --git a/user-input-with-forms/chapter-examples/form-submission.html b/user-input-with-forms/chapter-examples/form-submission.html new file mode 100644 index 0000000000..b3ecbf8007 --- /dev/null +++ b/user-input-with-forms/chapter-examples/form-submission.html @@ -0,0 +1,25 @@ + + + + + Form Example + + + + +
+ + + +
+ + diff --git a/user-input-with-forms/chapter-examples/form-validation/index.html b/user-input-with-forms/chapter-examples/form-validation/index.html new file mode 100644 index 0000000000..6b069f0363 --- /dev/null +++ b/user-input-with-forms/chapter-examples/form-validation/index.html @@ -0,0 +1,26 @@ + + + + + Form Validation + + + + +
+ + + +
+ + diff --git a/user-input-with-forms/chapter-examples/form-validation/script.js b/user-input-with-forms/chapter-examples/form-validation/script.js new file mode 100644 index 0000000000..a278f36a14 --- /dev/null +++ b/user-input-with-forms/chapter-examples/form-validation/script.js @@ -0,0 +1 @@ +//Add Your Code Below diff --git a/user-input-with-forms/chapter-examples/form-validation/style.css b/user-input-with-forms/chapter-examples/form-validation/style.css new file mode 100644 index 0000000000..7bb53b2bdb --- /dev/null +++ b/user-input-with-forms/chapter-examples/form-validation/style.css @@ -0,0 +1 @@ +/*/ Add your Code Below /*/ From f7ea03081622527b3f35f72acd0b5a613b8d589f Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Mon, 9 Oct 2023 15:50:28 -0500 Subject: [PATCH 34/46] exercises and studio for user input --- user-input-with-forms/exercises/index.html | 18 ++++++++++++++++++ user-input-with-forms/exercises/script.js | 1 + user-input-with-forms/exercises/style.css | 1 + user-input-with-forms/studio/index.html | 19 +++++++++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 user-input-with-forms/exercises/index.html create mode 100644 user-input-with-forms/exercises/script.js create mode 100644 user-input-with-forms/exercises/style.css create mode 100644 user-input-with-forms/studio/index.html diff --git a/user-input-with-forms/exercises/index.html b/user-input-with-forms/exercises/index.html new file mode 100644 index 0000000000..24dad6a4a5 --- /dev/null +++ b/user-input-with-forms/exercises/index.html @@ -0,0 +1,18 @@ + + + + + Rocket Simulation + + + + + + +

WARNING: This ONLY works in replit if this "result" page is opened in its own window. Click the icon that shows a box with an arrow coming out of it. +

+ + + diff --git a/user-input-with-forms/exercises/script.js b/user-input-with-forms/exercises/script.js new file mode 100644 index 0000000000..8e41e69915 --- /dev/null +++ b/user-input-with-forms/exercises/script.js @@ -0,0 +1 @@ +//Code Your Solution Below diff --git a/user-input-with-forms/exercises/style.css b/user-input-with-forms/exercises/style.css new file mode 100644 index 0000000000..4829c2597c --- /dev/null +++ b/user-input-with-forms/exercises/style.css @@ -0,0 +1 @@ +/*/ Code Your Solution Below /*/ diff --git a/user-input-with-forms/studio/index.html b/user-input-with-forms/studio/index.html new file mode 100644 index 0000000000..e6bf6cb0af --- /dev/null +++ b/user-input-with-forms/studio/index.html @@ -0,0 +1,19 @@ + + + + + + + + + +
+ +
+ + From 0ca8e17c79ebc5e634897011c1c1acb6ce4e479e Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Tue, 10 Oct 2023 12:57:51 -0500 Subject: [PATCH 35/46] added remaining examples --- .../checkbox-inputs/index.html | 30 +++++++++++++++++++ .../checkbox-inputs/script.js | 1 + .../checkbox-inputs/style.css | 1 + 3 files changed, 32 insertions(+) create mode 100644 user-input-with-forms/chapter-examples/checkbox-inputs/index.html create mode 100644 user-input-with-forms/chapter-examples/checkbox-inputs/script.js create mode 100644 user-input-with-forms/chapter-examples/checkbox-inputs/style.css diff --git a/user-input-with-forms/chapter-examples/checkbox-inputs/index.html b/user-input-with-forms/chapter-examples/checkbox-inputs/index.html new file mode 100644 index 0000000000..283a7ec0a6 --- /dev/null +++ b/user-input-with-forms/chapter-examples/checkbox-inputs/index.html @@ -0,0 +1,30 @@ + + + + + + repl.it + + + +
+ + + + + +

Activities

+ + + + + +

Ingredients

+ + + + + +
+ + diff --git a/user-input-with-forms/chapter-examples/checkbox-inputs/script.js b/user-input-with-forms/chapter-examples/checkbox-inputs/script.js new file mode 100644 index 0000000000..8fbbcae5f3 --- /dev/null +++ b/user-input-with-forms/chapter-examples/checkbox-inputs/script.js @@ -0,0 +1 @@ +// Add Your Code Below diff --git a/user-input-with-forms/chapter-examples/checkbox-inputs/style.css b/user-input-with-forms/chapter-examples/checkbox-inputs/style.css new file mode 100644 index 0000000000..d36223064b --- /dev/null +++ b/user-input-with-forms/chapter-examples/checkbox-inputs/style.css @@ -0,0 +1 @@ +/*/ Add Your Code Below /*/ From 09fdc82404c8b1f36d78e94bb91db9f1211c9caa Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Mon, 16 Oct 2023 10:31:01 -0500 Subject: [PATCH 36/46] fetch chapter added with chapter-examples --- .../fetching-data/fetch-weather-part-1.html | 21 ++++++++++++ .../fetching-data/fetch-weather-part-2.html | 24 ++++++++++++++ .../fetching-data/fetch-weather-part-3.html | 32 +++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 fetch/chapter-examples/fetching-data/fetch-weather-part-1.html create mode 100644 fetch/chapter-examples/fetching-data/fetch-weather-part-2.html create mode 100644 fetch/chapter-examples/fetching-data/fetch-weather-part-3.html diff --git a/fetch/chapter-examples/fetching-data/fetch-weather-part-1.html b/fetch/chapter-examples/fetching-data/fetch-weather-part-1.html new file mode 100644 index 0000000000..2a7f5fdedb --- /dev/null +++ b/fetch/chapter-examples/fetching-data/fetch-weather-part-1.html @@ -0,0 +1,21 @@ + + + + + Launch Status + + + +

Launch Status

+ Weather Conditions +
+ +
+ + diff --git a/fetch/chapter-examples/fetching-data/fetch-weather-part-2.html b/fetch/chapter-examples/fetching-data/fetch-weather-part-2.html new file mode 100644 index 0000000000..0aeadd0827 --- /dev/null +++ b/fetch/chapter-examples/fetching-data/fetch-weather-part-2.html @@ -0,0 +1,24 @@ + + + + + Launch Status + + + +

Launch Status

+ Weather Conditions +
+ +
+ + diff --git a/fetch/chapter-examples/fetching-data/fetch-weather-part-3.html b/fetch/chapter-examples/fetching-data/fetch-weather-part-3.html new file mode 100644 index 0000000000..65a0c0cc4a --- /dev/null +++ b/fetch/chapter-examples/fetching-data/fetch-weather-part-3.html @@ -0,0 +1,32 @@ + + + + + Launch Status + + + +

Launch Status

+ Weather Conditions +
+ +
+ + From c701868ddffdd9acf81bac311d09703f563a5733 Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Mon, 16 Oct 2023 10:50:27 -0500 Subject: [PATCH 37/46] studio starter code --- fetch/studio/index.html | 16 ++++++++++++++++ fetch/studio/script.js | 1 + fetch/studio/style.css | 16 ++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 fetch/studio/index.html create mode 100644 fetch/studio/script.js create mode 100644 fetch/studio/style.css diff --git a/fetch/studio/index.html b/fetch/studio/index.html new file mode 100644 index 0000000000..e691ad674b --- /dev/null +++ b/fetch/studio/index.html @@ -0,0 +1,16 @@ + + + + + + Astronauts + + + + +

Astronauts

+
+ +
+ + diff --git a/fetch/studio/script.js b/fetch/studio/script.js new file mode 100644 index 0000000000..591ec836a7 --- /dev/null +++ b/fetch/studio/script.js @@ -0,0 +1 @@ +//TODO: Add Your Code Below diff --git a/fetch/studio/style.css b/fetch/studio/style.css new file mode 100644 index 0000000000..0536760b67 --- /dev/null +++ b/fetch/studio/style.css @@ -0,0 +1,16 @@ +.avatar { + border-radius: 50%; + height: 100px; + float:right; +} + +.astronaut { + border: 1px solid black; + display: flex; + justify-content: space-between; + width: 500px; + align-items: center; + padding: 5px; + margin-bottom: 20px; + border-radius: 6px; +} From 7cb367a38e9ad13314bc3745d5b449a1868c73df Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Tue, 24 Oct 2023 14:07:07 -0500 Subject: [PATCH 38/46] Update part-one-arrays.js comments --- arrays/exercises/part-one-arrays.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arrays/exercises/part-one-arrays.js b/arrays/exercises/part-one-arrays.js index 85a27f5537..92f4e45170 100644 --- a/arrays/exercises/part-one-arrays.js +++ b/arrays/exercises/part-one-arrays.js @@ -1,5 +1,5 @@ -//Create an array that can hold 4 items name practiceFile. +//Create an array called practiceFile with the following entry: 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. -//Use a SetValue to add the items "false", and "-4.6" to the array. Print the array to confirm the changes. +//Use a single .push() to add the following items: false, -4.6, and "87". Print the array to confirm the changes. From 211b8ccd2674fcad668839a8feb82767ac272cdd Mon Sep 17 00:00:00 2001 From: Sally Steuterman Date: Mon, 27 Nov 2023 13:24:26 -0600 Subject: [PATCH 39/46] Migrating to Node 20 --- loops/studio/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loops/studio/package.json b/loops/studio/package.json index b74d5c248f..7fa1050817 100644 --- a/loops/studio/package.json +++ b/loops/studio/package.json @@ -12,6 +12,6 @@ "readline-sync": "^1.4.10" }, "devDependencies": { - "jest": "^29.6.1" + "jest": "^29.7.0" } } From e00825ab53d552cda1efcce5051ae63d98485aa9 Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Thu, 28 Mar 2024 09:14:48 -0500 Subject: [PATCH 40/46] added comment for method section of exercises --- objects-and-math/exercises/ObjectExercises.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/objects-and-math/exercises/ObjectExercises.js b/objects-and-math/exercises/ObjectExercises.js index 03cc68bc3a..9a50cbdecc 100644 --- a/objects-and-math/exercises/ObjectExercises.js +++ b/objects-and-math/exercises/ObjectExercises.js @@ -15,8 +15,10 @@ let salamander = { // After you have created the other object literals, add the astronautID property to each one. +// Add a move method to each animal object + // Create an array to hold the animal objects. // Print out the relevant information about each animal. -// Start an animal race! \ No newline at end of file +// Start an animal race! From 68dc67b242b373bce376af577e7305e2ed8d0256 Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Thu, 28 Mar 2024 09:50:32 -0500 Subject: [PATCH 41/46] updated style href link --- css/exercises/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/css/exercises/index.html b/css/exercises/index.html index 69f47f9239..922e8e3885 100644 --- a/css/exercises/index.html +++ b/css/exercises/index.html @@ -4,7 +4,7 @@ CSS Exercises - + From fd02b7cab9265570f24549e2c92f889a6de99faf Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Thu, 28 Mar 2024 10:09:05 -0500 Subject: [PATCH 42/46] removed reference to repl.it --- user-input-with-forms/exercises/index.html | 4 ---- 1 file changed, 4 deletions(-) diff --git a/user-input-with-forms/exercises/index.html b/user-input-with-forms/exercises/index.html index 24dad6a4a5..00a01b39ed 100644 --- a/user-input-with-forms/exercises/index.html +++ b/user-input-with-forms/exercises/index.html @@ -9,10 +9,6 @@ - - -

WARNING: This ONLY works in replit if this "result" page is opened in its own window. Click the icon that shows a box with an arrow coming out of it. -

From c3f51a4cabac12f6a22051c9f6ae5e0161e6b573 Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Thu, 23 May 2024 09:51:32 -0500 Subject: [PATCH 43/46] added package.json with readline-sync --- arrays/exercises/package.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 arrays/exercises/package.json diff --git a/arrays/exercises/package.json b/arrays/exercises/package.json new file mode 100644 index 0000000000..65adf18429 --- /dev/null +++ b/arrays/exercises/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "readline-sync": "^1.4.10" + } +} From 90158cc18aa47e4b9bf17380e741fba9cdb00f8b Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Thu, 23 May 2024 10:08:32 -0500 Subject: [PATCH 44/46] added more detail for part 3 of studio --- functions/studio/studio-functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/studio/studio-functions.js b/functions/studio/studio-functions.js index d4c291ed1a..175fc7f439 100644 --- a/functions/studio/studio-functions.js +++ b/functions/studio/studio-functions.js @@ -17,7 +17,7 @@ // 4. Return the reversed number. // 5. Be sure to print the result returned by the function to verify that your code works for both strings and numbers. Do this before moving on to the next exercise. -// Part Three: Complete Reversal +// Part Three: Complete Reversal - Create a new function with one parameter, which is the array we want to change. The function should: // 1. Define and initialize an empty array. // 2. Loop through the old array. From c8e53bc4af3964c1b52d82db7b55ed9bd182fdde Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Thu, 23 May 2024 10:14:36 -0500 Subject: [PATCH 45/46] fixed spacing on comments --- more-on-functions/exercises/raid-a-shuttle.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/more-on-functions/exercises/raid-a-shuttle.js b/more-on-functions/exercises/raid-a-shuttle.js index 507a67ccc5..db663e4177 100644 --- a/more-on-functions/exercises/raid-a-shuttle.js +++ b/more-on-functions/exercises/raid-a-shuttle.js @@ -25,7 +25,7 @@ console.log("Fuel level: " + checkFuel(fuelLevel)); console.log("Hold status: " + holdStatus(cargoHold)); /* Steal some fuel from the shuttle: - * / + */ //a). Define an anonymous function and set it equal to a variable with a normal, non-suspicious name. The function takes one parameter. This will be the fuel level on the shuttle. @@ -36,7 +36,7 @@ console.log("Hold status: " + holdStatus(cargoHold)); //d). Decide where to best place your function call to gather our new fuel. /* Next, liberate some of that glorious cargo. - * / + */ //a). Define another anonymous function with an array as a parameter, and set it equal to another innocent variable. @@ -47,11 +47,10 @@ console.log("Hold status: " + holdStatus(cargoHold)); //d). Don’t get hasty, matey! Remember to test your function. /* Finally, you need to print a receipt for the accountant. Don’t laugh! That genius knows MATH and saves us more gold than you can imagine. - * / + */ //a). Define a function called irs that can take fuelLevel and cargoHold as arguments. //b). Call your anonymous fuel and cargo functions from within irs. -//c). Use a template literal to return, "Raided _____ kg of fuel from the tanks, and stole ____ and ____ from the cargo hold." - +//c). Use a template literal to return, "Raided _____ kg of fuel from the tanks, and stole ____ and ____ from the cargo hold." \ No newline at end of file From f473f592842a9f5cbbfedecf748a2aac82a610e2 Mon Sep 17 00:00:00 2001 From: John Woolbright Date: Thu, 23 May 2024 10:37:49 -0500 Subject: [PATCH 46/46] fixed typo --- more-on-functions/studio/part-three-number-sorting-easy-way.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/more-on-functions/studio/part-three-number-sorting-easy-way.js b/more-on-functions/studio/part-three-number-sorting-easy-way.js index 386cde1da8..bfa9748a32 100644 --- a/more-on-functions/studio/part-three-number-sorting-easy-way.js +++ b/more-on-functions/studio/part-three-number-sorting-easy-way.js @@ -5,4 +5,4 @@ let nums3 = [200, 5, 4, 10, 8, 5, -3.3, 4.4, 0]; //Sort each array in ascending order. -//Sort each array in decending order. +//Sort each array in descending order.