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/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" + } +} 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..92f4e45170 --- /dev/null +++ b/arrays/exercises/part-one-arrays.js @@ -0,0 +1,5 @@ +//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 single .push() to add the following items: false, -4.6, and "87". 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. 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..3d7d4ea580 --- /dev/null +++ b/arrays/studio/array-string-conversion/spec/array-testing.spec.js @@ -0,0 +1,31 @@ +/** + * @jest-environment node + */ + +//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. diff --git a/booleans-and-conditionals/exercises/part-1.js b/booleans-and-conditionals/exercises/part-1.js new file mode 100644 index 0000000000..b829140a07 --- /dev/null +++ b/booleans-and-conditionals/exercises/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/exercises/part-2.js b/booleans-and-conditionals/exercises/part-2.js new file mode 100644 index 0000000000..ff11fbab8a --- /dev/null +++ b/booleans-and-conditionals/exercises/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/exercises/part-3.js b/booleans-and-conditionals/exercises/part-3.js new file mode 100644 index 0000000000..9ed686d097 --- /dev/null +++ b/booleans-and-conditionals/exercises/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!" */ 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..6a15e146f4 --- /dev/null +++ b/booleans-and-conditionals/studio/data-variables-conditionals.js @@ -0,0 +1,15 @@ +// Initialize Variables below + +// add logic below to verify total number of astronauts for shuttle launch does not exceed 7 + +// add logic below to verify all astronauts are ready + +// add logic below to verify the total mass does not exceed the maximum limit of 850000 + +// add logic below to verify the fuel temperature is within the appropriate range of -150 and -300 + +// add logic below to verify the fuel level is at 100% + +// add logic below to verify the weather status is clear + +// Verify shuttle launch can proceed based on above conditions 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 diff --git a/css/exercises/index.html b/css/exercises/index.html new file mode 100644 index 0000000000..922e8e3885 --- /dev/null +++ b/css/exercises/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/exercises/script.js b/css/exercises/script.js new file mode 100644 index 0000000000..3bbac89f48 --- /dev/null +++ b/css/exercises/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/exercises/styles.css b/css/exercises/styles.css new file mode 100644 index 0000000000..3b88bed453 --- /dev/null +++ b/css/exercises/styles.css @@ -0,0 +1 @@ +/* Start adding your styling below! */ 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); 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; +} 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 0000000000..07174271f3 Binary files /dev/null and b/dom-and-events/studio/LaunchCode_rocketline_white.png differ diff --git a/dom-and-events/studio/index.html b/dom-and-events/studio/index.html new file mode 100644 index 0000000000..1efd507e53 --- /dev/null +++ b/dom-and-events/studio/index.html @@ -0,0 +1,40 @@ + + + + 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 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/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); 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..a656080d25 --- /dev/null +++ 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."); +} 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 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); 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 +
+ +
+ + 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; +} diff --git a/functions/studio/studio-functions.js b/functions/studio/studio-functions.js new file mode 100644 index 0000000000..175fc7f439 --- /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 - 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. +// 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!"); +} 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 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 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..7fa1050817 --- /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.7.0" + } +} 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 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 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." \ No newline at end of file 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..bfa9748a32 --- /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 descending 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]; 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..9a50cbdecc --- /dev/null +++ b/objects-and-math/exercises/ObjectExercises.js @@ -0,0 +1,24 @@ +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. + +// 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! 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 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); 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'. 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 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/palindrome-example/package.json b/unit-testing/chapter-examples/palindrome-example/package.json new file mode 100644 index 0000000000..554413f472 --- /dev/null +++ b/unit-testing/chapter-examples/palindrome-example/package.json @@ -0,0 +1,17 @@ +{ + "name": "unit-testing", + "version": "1.0.0", + "description": "", + "main": "palindrome.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/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/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 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 /*/ 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 /*/ diff --git a/user-input-with-forms/exercises/index.html b/user-input-with-forms/exercises/index.html new file mode 100644 index 0000000000..00a01b39ed --- /dev/null +++ b/user-input-with-forms/exercises/index.html @@ -0,0 +1,14 @@ + + + + + Rocket Simulation + + + + + + + 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 @@ + + + + + + + + + +
+ +
+ +