From df98ab5a7fb889a906475213b1655a0476cbb374 Mon Sep 17 00:00:00 2001 From: Eric Li Date: Sat, 27 Mar 2021 19:44:17 -0600 Subject: [PATCH 01/10] Add Section 1 --- section1/exercises/concatenation.js | 21 +++++++++++++-------- section1/exercises/dataTypes.js | 20 +++++++++++--------- section1/exercises/interpolation.js | 20 +++++++++++++------- section1/exercises/variables.js | 28 ++++++++++++++++++++-------- section1/relection.md | 24 +++++++++++++++++++++++- 5 files changed, 80 insertions(+), 33 deletions(-) diff --git a/section1/exercises/concatenation.js b/section1/exercises/concatenation.js index d51387638..1f07db8aa 100644 --- a/section1/exercises/concatenation.js +++ b/section1/exercises/concatenation.js @@ -6,7 +6,7 @@ One example is already completed. Your task is to complete any remaining prompt. When navigated to the root of this project directory, you should be able to run this -file from your terminal with the command `node section1/exercises/dataTypes.js` +file from your terminal with the command `node section1/exercises/concatenation.js` */ // EXAMPLE: Write code that combines the variables below into another string: @@ -19,17 +19,19 @@ console.log("The " + team + " are " + name + "'s favorite Quidditch team"); var numberOfCreatures = 7; var creatures = "unicorns"; -console.log("My zoo has " + numberOfCreatures + " " + creatures + "!") +console.log("My zoo has " + numberOfCreatures + " " + creatures + "!"); // YOU DO: What data type will be logged to the console as a result of line 22? Explain. -// Your answer and explanation here: +// Your answer and explanation here: +// My zoo has 7 unicorns! I placed the variables for numberOfCreatures and creatures in between the strings for "My zoo has ", " ", and "!" // YOU DO: // Write code that combines the variables below into a string that // reads "The quick red fox jumped over the lazy brown dog": var speedy = "quick red fox"; var slowPoke = "lazy brown dog"; +console.log("The " + speedy + " jumped over the " + slowPoke); // YOU DO: @@ -39,17 +41,20 @@ var slowPoke = "lazy brown dog"; slowPoke = "tortoise"; speedy = "hare"; - +console.log("In a predictable result, the " + slowPoke + " beat the " + speedy + "!"); // YOU DO: -// Declare three variables, name/content/data type of your choice. Think carefully about what +// Declare three variables, name/content/data type of your choice. Think carefully about what // you name the variables. Remember, the goal is to be concise but descriptive (it's a hard balance!) // Then, log out ONE sentence that incorporates all THREE variables. - +var numberOfWheels = 3; +var drink = "potion"; +var action = "Took another sip"; +console.log(action + " of the " + drink + ", hit the " + numberOfWheels + "-wheel motion"); //------------------- // FINAL CHECK //------------------- -// Did you run this file in your terminal to make sure everything printed out to the console - // as you would expect? You should be doing this by now, and getting into the habit of it. \ No newline at end of file +// Did you run this file in your terminal to make sure everything printed out to the console + // as you would expect? You should be doing this by now, and getting into the habit of it. diff --git a/section1/exercises/dataTypes.js b/section1/exercises/dataTypes.js index 5fd9233e7..1d101a5d9 100644 --- a/section1/exercises/dataTypes.js +++ b/section1/exercises/dataTypes.js @@ -1,6 +1,6 @@ /* In the exercises below, write your own code where indicated -to achieve the desired result. +to achieve the desired result. Each section has 2 examples that are already completed. Your task is to complete any remaining prompt in each section. @@ -21,10 +21,10 @@ console.log("Alan Turing"); console.log('Welcome to Turing!'); // YOU DO: Write code below to log `99 bottles of pop on the wall...`: - +console.log('99 bottles of pop on the wall...'); // YOU DO: Write code below to log one line from your favorite song or movie: - +console.log("Life's simple. You make choices, and you don't look back."); //------------------- @@ -38,13 +38,13 @@ console.log(2 + 2); console.log(83 - 7); // YOU DO: log the result of 6 multiplied by 53 to the console: - +console.log(6 * 53); // YOU DO: log the result of 20 divided by 4 to console: - +console.log(20 / 4); // YOU DO: log the result of the modulo of 10 into 54: - +console.log(54 % 10); //------------------- @@ -58,16 +58,18 @@ console.log(1 === 2); console.log(7 > 2); // YOU DO: log to the console the result of "hello" is equal to "Hello": +console.log("hello" === "Hello"); // YOU DO: log to the console the result of 3 is not equal to 4: +console.log(3 != 4); // YOU DO: log to the console the result of 4 is less than or equal to 5: - +console.log(4 <= 5); //------------------- // FINAL CHECK //------------------- -// Did you run this file in your terminal to make sure everything printed out to the console -// as you would expect? \ No newline at end of file +// Did you run this file in your terminal to make sure everything printed out to the console +// as you would expect? diff --git a/section1/exercises/interpolation.js b/section1/exercises/interpolation.js index 35e332b89..fab5bee19 100644 --- a/section1/exercises/interpolation.js +++ b/section1/exercises/interpolation.js @@ -22,7 +22,9 @@ var creatures = "unicorns"; console.log( `My zoo has ${numberOfCreatures} ${creatures}!`); // YOU DO: What data type will be logged to the console as a result of line 22? Explain. -// Your answer and explanation here: +// Your answer and explanation here: + +// A string saying 'My zoo has 7 unicorns' will be logged to the console as a result of interpolation. // YOU DO: @@ -30,26 +32,30 @@ console.log( `My zoo has ${numberOfCreatures} ${creatures}!`); // reads "The quick red fox jumped over the lazy brown dog": var speedy = "quick red fox"; var slowPoke = "lazy brown dog"; +console.log( `The ${speedy} jumped over the ${slowPoke}`); // YOU DO: // Write code that combines the variables below into a string that // reads "In a predictable result, the tortoise beat the hare!" // Note that we are omitting the var keyword below, because we are re-assigning the variables - slowPoke = "tortoise"; speedy = "hare"; +console.log( `In a predictable result, the ${slowPoke} beat the ${speedy}!`) // YOU DO: -// Declare three variables, name/content/data type of your choice. Think carefully about what +// Declare three variables, name/content/data type of your choice. Think carefully about what // you name the variables. Remember, the goal is to be concise but descriptive (it's a hard balance!) - // Then, log out ONE sentence that incorporates all THREE variables uisng interpolation. - + // Then, log out ONE sentence that incorporates all THREE variables uisng interpolation. +var numberOfWheels = 3; +var drink = "potion"; +var action = "Took another sip"; +console.log( `${action} of the ${drink}, hit the ${numberOfWheels}-wheel motion`); //------------------- // FINAL CHECK //------------------- -// Did you run this file in your terminal to make sure everything printed out to the console - // as you would expect? You should be doing this by now, and getting into the habit of it. \ No newline at end of file +// Did you run this file in your terminal to make sure everything printed out to the console + // as you would expect? You should be doing this by now, and getting into the habit of it. diff --git a/section1/exercises/variables.js b/section1/exercises/variables.js index 05684b001..b9619df49 100644 --- a/section1/exercises/variables.js +++ b/section1/exercises/variables.js @@ -17,39 +17,51 @@ console.log(name); // EXAMPLE: Write code below to add 2 to the variable `students` and // log the result: -var enrolledStudents = 22; +var enrolledStudents = 2; console.log(enrolledStudents); // YOU DO: // Write code below to save the string 'Harry Potter must not return to Hogwarts!' // log that variable to the console. - +var harryPotter = 'Harry Potter must not return to Hogwarts!'; +console.log(harryPotter); // YOU DO: -// Declare three variables, named `firstName`, `isHungry` and `numberOfPets`. +// Declare three variables, named `firstName`, `isHungry` and `numberOfPets`. // Store the appropriate data types in each. // log all three variables to the console. +var firstName = 'Eric'; +var isHungry = 'no'; +var numberOfPets = 0; +console.log(firstName, isHungry, numberOfPets); // IN WORDS: -// How did you decide to use the data type you did for each of the three variables above? +// How did you decide to use the data type you did for each of the three variables above? // Explain. +// I just read the variable name and from the titles, I found out whether to input a number or string." // YOU DO: -// Re-assign the values to the three variables from the previous challenge to different +// Re-assign the values to the three variables from the previous challenge to different // values (but same data type). // log all three variables to the console. - +firstName = 'Larry'; +isHungry = 'yes'; +numberOfPets = 25; +console.log(firstName, isHungry, numberOfPets); // YOU DO: // Using the variables below, log the total number of snacks to the console: var healthySnacks = 6; var junkFoodSnacks = 8; +var totalSnacks = healthySnacks + junkFoodSnacks; +console.log(totalSnacks); + //------------------- // FINAL CHECK //------------------- -// Did you run this file in your terminal to make sure everything printed out to the console -// as you would expect? \ No newline at end of file +// Did you run this file in your terminal to make sure everything printed out to the console +// as you would expect? diff --git a/section1/relection.md b/section1/relection.md index 13890be28..ee38c6f7a 100644 --- a/section1/relection.md +++ b/section1/relection.md @@ -2,18 +2,40 @@ 1. How did the SuperLearner Article resonate with you? What from this list do you already do? Want to start doing or do more of? Is there anything not on this list, that you would add to it? +I like teaching and helping my other classmates with the homework, and I also have a strong growth mindset. I would like to read more and get better at break-taking. I would add to this, "Always work one step at a time. Don't think of a new goal as daunting, just do the next step." + 2. What are the data types you learned about in this section? In your own words, define each. +Number - denotes a numerical value. Can be 0, pos/neg, or a decimal. + +String - phrases - Letters and other characters wrapped within '' or "" + 3. How would you log the string `"Hello World!"` to the console? +`console.log("Hello World!");` + 4. What is/are the character(s) you would use to indicate comments in a JavaScript file? What is the purpose of a code comment? +// before the comment text. The purpose is so that programmers other than the creator of the code can see what they were trying to do, what problems they ran into, etc. + 5. In your own words, what is a variable? How would you explain it to a 5 year old? +A changeable value. The calendar date is a variable. It changes every day. + 6. Think of a site or app you use frequently. What are three variables that are probably used? Which data type would each of those variables probably hold? +Reddit probably uses a variable for the page number (number), thumbs up (number/string), and homepage algorithm (string). + 7. In your own words, explain what concatenation is. +Concatenation is like adding variables in between strings, to log a complete string. + 8. Think of a site or app you use frequently. Where do you think the developers used concatention? -9. What questions do you still have about the work we've done so far? (not having a question is not an option) \ No newline at end of file +Facebook. "What's on your mind, Eric?" + +9. What questions do you still have about the work we've done so far? (not having a question is not an option) + +I'm wondering if the syntax for the non-code answers was correct for my exercises. I entered them using the // notes format. + +Just to confirm, when you make multiple file changes, you should add and commit them separately, right? I believe mod 0 session 3 I made a mistake in putting a file add and adding text in one commit. From cd039ddaa32ed0d9c955d06b565813270aefdd9e Mon Sep 17 00:00:00 2001 From: Eric Li Date: Mon, 29 Mar 2021 14:21:23 -0600 Subject: [PATCH 02/10] Add Section 2 work --- section2/exercises/comparisons.js | 24 +++++++++--- section2/exercises/decision-making.js | 38 +++++++++++++++++-- section2/exercises/functions.js | 34 ++++++++++++++--- section2/exercises/if-statements.js | 53 +++++++++++++++++++-------- section2/reflection.md | 11 ++++++ 5 files changed, 131 insertions(+), 29 deletions(-) diff --git a/section2/exercises/comparisons.js b/section2/exercises/comparisons.js index 813c145aa..eefda86dc 100644 --- a/section2/exercises/comparisons.js +++ b/section2/exercises/comparisons.js @@ -24,9 +24,11 @@ console.log("Is numberTeachers greater than numberStudents?", numberTeachers > n // YOU DO: log the result of the comparison: is numberTeachers less than numberStudents? // this should log: true +console.log("Is numberTeachers less than numberStudents?", numberTeachers < numberStudents); // YOU DO: log the result of the comparison: is numberTeachers equal to stringTeachers? (use the == operator) // this should log: true +console.log("Is numberTeachers equal to stringTeachers?", numberTeachers == stringTeachers); /* Note: this is an example of type coercion. Although stringTeachers is a string and numberStudents is an integer, @@ -36,7 +38,7 @@ perform this evaluation // YOU DO: log the result of the comparison: is numberTeachers strictly equal to stringTeachers? (use the === operator) // this should log: false - +console.log("Is numberTeachers strictly equal to stringTeachers?", numberTeachers === stringTeachers); /* Note: the strictly equal to operator compares the value of the variable in addition to the type of the variable. since the numberTeachers is an integer value and the stringTeachers is a string value, although they are both equal to 4, @@ -49,18 +51,23 @@ you develop good habits that follow best practice, from now on, use the strict c // YOU DO: log the result of the comparison: is numberTeachers not equal to numberStudents? // this should log: true +console.log("Is numberTeachers not equal to numberStudents?", numberTeachers != numberStudents); // YOU DO: log the result of the comparison: is numberStudents greater than or equal to 20? // this should log: true +console.log("Is numberStudents greater than or equal to 20?", numberStudents >= 20); // YOU DO: log the result of the comparison: is numberStudents greater than or equal to 21? // this should log: false +console.log("Is numberStudents greater than or equal to 21?", numberStudents >= 21); // YOU DO: log the result of the comparison: is numberStudents less than or equal to 20? // this should log: true +console.log("Is numberStudents less than or equal to 20?", numberStudents <= 20); // YOU DO: log the result of the comparison: is numberStudents less than or equal to 21? // this should log: true +console.log("Is numberStudents less than or equal to 21?", numberStudents <= 21); //------------------- @@ -74,20 +81,24 @@ you develop good habits that follow best practice, from now on, use the strict c console.log(4 < 9); //YOU DO: Explain. +// True. 4 is indeed less than 9. var books = 3; -console.logs(4 < books); +console.log(4 < books); // YOU DO: Explain. +// False. If the value of variable books = 3, 4 cannot be less than books. var friends = 6; var siblings = 2; console.log(friends > siblings); // YOU DO: Explain. +// True. If the value of variable friends = 6 and the value of variable siblings = 2, friends is greater than siblings. var attendees = 9; var meals = 8; console.log(attendees !== meals); // YOU DO: Explain. +// True. !== means not equal to. If the value of variable attendees is 9 and the value of variable meals is 8, the two values are in fact not equal. //------------------- @@ -110,18 +121,21 @@ var age = 1; // YOU DO: // Determine if the dog loves to play and loves treats - +console.log(lovesToPlay && lovesTreats); // Determine if the dog loves to play and loves the dog park - +console.log(lovesToPlay && lovesDogPark); // Determine if the dog loves to play or loves the dog park - +console.log(lovesToPlay || lovesDogPark); // Determine if the dog loves to play and is a puppy +console.log(lovesToPlay && age <= 1) // What did your final line of code evaluate to? Why do you think that is? Explain. // ANSWER: +// I assumed that the cut off age for a puppy was 1 years old. Using that information I used a comparison operator to ask if the value of +// age was less than or equal to 1, and I used the logical operator `&&` to see if the dog was a puppy AND loves to play. //------------------- // FINAL CHECK diff --git a/section2/exercises/decision-making.js b/section2/exercises/decision-making.js index 97c433121..75cd770c2 100644 --- a/section2/exercises/decision-making.js +++ b/section2/exercises/decision-making.js @@ -5,16 +5,16 @@ Below is a dynamic story that is created based on the value of three variables: Spend some time changing the variables and running the file to see how the story changes. */ -var doorChoice = 1; +var doorChoice = 2; var bearClothing = ""; -var bearChoice = 1; +var bearChoice = 3; console.log("You enter a dark room with two doors. Do you go through #1 or #2?"); if (doorChoice === 1) { bearClothing = "hat"; } else { - bearClothing = "scarf"; + bearClothing = "shirt"; } console.log("You see a bear putting on a " + bearClothing); @@ -29,7 +29,7 @@ if (bearChoice === 1) { } else if (bearChoice === 2) { console.log("You tell the bear the " + bearClothing + " is too small and it starts to cry!"); } else if (bearChoice === 3) { - console.log("You run as fast as you can into the next room. It's full of snakes!"); + console.log("You run as fast as you can into the next room. It's full of a complete and healthy breakfast. Yum!"); } else { console.log("You stay with the bear and become it's best friend!"); } @@ -38,16 +38,46 @@ if (bearChoice === 1) { Questions 1. In English, using technical vocabulary, describe what is happening between lines 14 and 18. + We are using if to show that if the condition is met, or true, the line of code under if will be run. Else is used to show + that if the condition is not met, or false, the line under else will be run. + + In this case, we are using the comparison operator === to indicate the condition will result in true if the variable bearChoice + is exactly equals to 1. + + Any value other than 1 will result in a false. If the condition is met, or if variable bearClothing changes to "hat". If the + condition is not met, or else, the variable bearClothing changes to "shirt". 2. What variable has a new value assigned to it after the first if statement executes? + bearClothing 3. If you changed the variable doorChoice to equal 3, what would the bearClothing value be? + "shirt" 4. In English, using technical vocabulary, describe what is happening between lines lines 27 and 35. + Now we are using else if statements. In conjunction to the if statement, with the condition of "variable bearChoice is exactly + equals 1 resulting in a true statement, we have these else if statements. + + If bearChoice exactly equals 1, the script "You offer the bear your " + bearClothing value + " and the bear shows you a + secret passage out!" will be logged. + + else if bear choice exactly equals 2, the script "You tell the bear the " + bearClothing value + " is too small and it starts to cry!" + will be logged. + + else if bear choice exactly equals 3, the script "You run as fast as you can into the next room. It's full of a healthy and complete + breakfast. Yum!" will be logged. + + else, the script "You stay with the bear and become it's best friend!" will be logged. + + Else if statements are assuming the if statement or previous else if statement is not met, if they are met, the line of code under them is + run. 5. If you changed the variable bearChoice to equal 3, what will be the final outcome be? + The script "You run as fast as you can into the next room. It's full of a healthy and complete + breakfast. Yum!" is logged to the console. 6. If you changed the variable doorChoice to equal 1, and the variable bearChoice to equal 2, what will be the final outcome be? + The script "You tell the bear the hat is too small and it starts to cry!" will be logged to the console. 7. What is your favorite ending? + The breakfast ending for bearChoice = 3. So vague. Eggs Benedict? Waffle House? IHOP? Either way I'm hungry now. */ diff --git a/section2/exercises/functions.js b/section2/exercises/functions.js index 67fdc67c4..ba8bcc75f 100644 --- a/section2/exercises/functions.js +++ b/section2/exercises/functions.js @@ -15,9 +15,9 @@ Make sure to run the file with node in your command line. // EXAMPLE: Write a function below that, when called will log "Severus Snape" to the console function printName() { console.log("Severus Snape"); -}; +} -printName(); +printName(); printName(); printName(); printName(); @@ -26,7 +26,12 @@ printName(); // YOU DO: Write a function named sayHello that logs to the console "Oh, Hello!" // Then, call the function 2 times. +function sayHello() { + console.log("Oh, Hello!"); +} +sayHello(); +sayHello(); //------------------- // PART 2: Arguments and Parameters //------------------- @@ -34,19 +39,34 @@ printName(); // YOU DO: Write a function named greetMe that takes an argument, a String, of a name. // The function should print out the value of the String that was passed in. // Then, call the function 3 times, each time, passing it a different name. +function greetMe(name) { + console.log("Hi, " + name + "!"); +} - +greetMe('Eric'); +greetMe("Casey"); +greetMe("Brian"); // YOU DO: Write a function that takes in 2 numbers as arguments, Numbers, and logs their sum // Then, call that function 3 times, each time, passing in 2 different Numbers. +function dogCount(puppyCount, adultCount) { + var sum = puppyCount + adultCount; + console.log('I have ' + sum + ' dogs.'); +} +dogCount(12, 4); +dogCount(3, 2); +dogCount(5, 2); // YOU DO🎈: Write a function that takes in two strings and prints a concatenation // of those two strings, for example the arguments could be ("Oscar", "Ruck") and // the end result might be "Oscar and Ruck are BFFS". Then, call that function. +function whichFish(fishOne, fishTwo) { + console.log("I caught " + fishOne + " and " + fishTwo + " today."); +} - +whichFish("Trout", "Pike"); //------------------- // PART 3: Naming is Hard @@ -61,5 +81,9 @@ What did you name each parameter, and why? EXPLAIN: +I named the function whichFish. In order to name the function, I first looked at what the code block under the +function line was going to run. It seems like it's answering the question "Which fish did I catch today?". for +the parameters I set them as fishOne and fishTwo, just to differentiate them and also to keep it all letters. -*/ \ No newline at end of file + +*/ diff --git a/section2/exercises/if-statements.js b/section2/exercises/if-statements.js index d8779fc29..51b4ab956 100644 --- a/section2/exercises/if-statements.js +++ b/section2/exercises/if-statements.js @@ -12,7 +12,7 @@ Make sure to run the file with node in your command line. // EXAMPLE:Manipulate the variable 'weather' to see if you can print something other // than 'coat'. -var weather = 'snowy'; +var weather = 'sunny'; // var weather = 'icy'; // var weather = 'rainy'; // var weather = 'sunny'; @@ -31,20 +31,31 @@ if (weather == 'sunny') { console.log('good to go!'); } -/* +/* YOU DO: -Using the dogAge variable defined below, -determine if a dog is a puppy (2 or younger), +Using the dogAge variable defined below, +determine if a dog is a puppy (2 or younger), an adult, or elderly (10 or older). Log to the console the appropriate age range (puppy, adult, elderly). */ -var dogAge = 3; -// Write your conditional here +var dogAge = 2; + +// Write your conditional here +if (dogAge <= 2) { + console.log("Puppy"); +} else if (dogAge < 10) { + console.log("Adult"); +} else if (dogAge >= 10) { + console.log("Elderly"); +} else{ + console.log("Woof-woof!"); +} + /* YOU DO: Using the numQuarters variable defined below, determine @@ -55,18 +66,21 @@ out both "I have enough money for a gumball" and a conditional statement that ONLY logs one or the other. -You should be able to change num_quarters and achieve these outputs: +You should be able to change numquarters and achieve these outputs: When numQuarters = 0, program should log "I don't have enough money for a gumball" When numQuarters = 1, program should log "I don't have enough money for a gumball" When numQuarters = 2, program should log "I have enough money for a gumball" When numQuarters = 3, program should log "I have enough money for a gumball" */ -var numQuarters = 0; +var numQuarters = 3; // Write your conditional here -console.log("I have enough money for a gumball"); -console.log("I don't have enough money for a gumball"); +if (numQuarters >= 2) { + console.log("I have enough money for a gumball"); +} else { + console.log("I don't have enough money for a gumball"); +} /* @@ -82,15 +96,24 @@ When cupsOfFlour = 2 and hasSauce = true, your program should log "I can make pi When cupsOfFlour = 3 and hasSauce = true, your program should log "I can make pizza"; */ -var cupsOfFlour = 1; -var hasSauce = true; +var cupsOfFlour = 2; +var hasSauce = false; // Write your conditional here - +if (cupsOfFlour >= 2 && hasSauce === true) { + console.log("I can make pizza"); +} else { + console.log("I cannot make pizza"); +} /* -For the last two exercises, an ideal solution probably uses a logical operator. +For the last two exercises, an ideal solution probably uses a logical operator. Did yours? Do you know what a logical operator in JavaScript is? Google it to answer for yourself! -*/ \ No newline at end of file +I think that the last one needed one but I can't see why the gumball one would. The && was +useful because I need both hasSauce to be true and cupsOfFlour to be greater than 2 to make +pizza. Logical operators like and (&&) and or (||) help us when we need two coniditions at +the same time in an if statement. + +*/ diff --git a/section2/reflection.md b/section2/reflection.md index 0940eccce..7a255ca8b 100644 --- a/section2/reflection.md +++ b/section2/reflection.md @@ -2,12 +2,23 @@ 1. Regarding the blog posts in Part A, how do you feel about asking questions? Do you tend to ask them too soon, or wait too long, or somewhere in between? +I feel like I wait too long sometimes, but so far I have been able to figure roadblocks out myself at a reasonable rate. + 1. In this section, we removed some of the supports that you had in Section 1. We didn't give the directions for how to run a file in node, and really sent you off to learn about functions by exploring several outside resources. How did that feel? What was uncomfortable about it? How did it support your learning? +I like that it builds the muscle memory I need to learn a coding language. That in addition to repetition really helps build a strong foundation. It was a bit uncomfortable for the functions exercise at first when it asked to show a sum of two parameters. I kept getting 1+2=12 when trying to log the sum. I searched that one on Google for awhile, and the answer was pretty simple. It helped my Googling skills and to remember to keep it simple. + 1. What is a conditional statement? Give one example of a daily life conditional. Give one example of where a conditional is probably used in a web application you use. +A conditional statement is a statement, when run, that returns a true or false value. "Am I Hungry?" returns a "yes" or "no". I think Facebook might use conditionals for reactions, if they are clicked, the reaction sends, otherwise, the reaction does not send. + 1. How do you add multiple conditions to an `if` statement? In your own words, explain how to program reads them and determines what to do. +You use the `else if` statement to add additional conditions to an `if` statement. If the condition for the `if` statement is false, and the `else if` is true, then the block of code under the `else if` is run. + 1. What tools are available to you, as a developer, if you want to check that TWO conditions are met? Or, if you want to check that 1 of 2 conditions are met, before running a block of code? +I think that logical operators like AND (&&) and OR (||) are useful in helping with this task. 1. What questions do you still have about `if` statements and/or functions? + +I'm wondering if I did functions part two, the question with the sum correctly. Also, when we want to log a variable in between scripts we can use both concatenation AND interpolation right? From e82aa3c9eafc7a958c143a099eae5f7008c5bdeb Mon Sep 17 00:00:00 2001 From: Eric Li Date: Tue, 30 Mar 2021 17:39:16 -0600 Subject: [PATCH 03/10] Edit comparisons.js --- section2/exercises/comparisons.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/section2/exercises/comparisons.js b/section2/exercises/comparisons.js index eefda86dc..f8316d5d0 100644 --- a/section2/exercises/comparisons.js +++ b/section2/exercises/comparisons.js @@ -81,24 +81,26 @@ console.log("Is numberStudents less than or equal to 21?", numberStudents <= 21) console.log(4 < 9); //YOU DO: Explain. -// True. 4 is indeed less than 9. +// 4 is indeed less than 9. True will be logged to the console. var books = 3; console.log(4 < books); // YOU DO: Explain. -// False. If the value of variable books = 3, 4 cannot be less than books. +// Declare variable books. If the value of variable books = 3, 4 cannot be less than books. False will be logged to the console. var friends = 6; var siblings = 2; console.log(friends > siblings); // YOU DO: Explain. -// True. If the value of variable friends = 6 and the value of variable siblings = 2, friends is greater than siblings. +// Declare variables friends and siblings. True. If the value of variable friends = 6 and the value of variable siblings = 2, friends is greater +// than siblings. True will be logged to the console. var attendees = 9; var meals = 8; console.log(attendees !== meals); // YOU DO: Explain. -// True. !== means not equal to. If the value of variable attendees is 9 and the value of variable meals is 8, the two values are in fact not equal. +// !== means not equal to. If the value of variable attendees is 9 and the value of variable meals is 8, the two values are in fact not equal. +// True will be logged to the console. //------------------- From d9b9c0daba50d0266e69c14d12f6348d0f8a3ba4 Mon Sep 17 00:00:00 2001 From: Eric Li Date: Tue, 30 Mar 2021 20:26:56 -0600 Subject: [PATCH 04/10] Add Section 3 --- section3/arrayMethods.md | 9 ++++ section3/exercises/arrays.js | 68 +++++++++++++++++++++--------- section3/exercises/loops-arrays.js | 24 ++++++++++- section3/exercises/loops.js | 22 ++++++++-- section3/reflection.md | 19 ++++++++- 5 files changed, 117 insertions(+), 25 deletions(-) create mode 100644 section3/arrayMethods.md diff --git a/section3/arrayMethods.md b/section3/arrayMethods.md new file mode 100644 index 000000000..5f787aedb --- /dev/null +++ b/section3/arrayMethods.md @@ -0,0 +1,9 @@ +## Session 3 - Array Methods + +1. Pop removes the last item on an array and returns the value to the caller. For example, if the last item is 'potato', it will remove 'potato' from the array and 'potato' will be logged if we use `console.log()` + +2. Push adds one or more item to the end of an array and returns to the caller the new length value. For example, we can add 'peanut' to [cabbage, kale, strawberry] using push and the new array would look like [cabbage, kale, strawberry, peanut], returning to the caller a value of 4. + +3. Shift removes the first item on an array and returns the value to the caller. For example, if the first item is 'potato', it will remove 'potato' from the array, and 'potato' will be logged if we use `console.log()`. + +4. Unshift adds one or more item to the beginning of an array and returns to the caller the new length value. For example, we can add 'peanut' to [cabbage, kale, strawberry] using push and the new array would look like [peanut, cabbage, kale, strawberry], returning to the caller a value of 4. diff --git a/section3/exercises/arrays.js b/section3/exercises/arrays.js index 5103ae13e..cddfdf022 100644 --- a/section3/exercises/arrays.js +++ b/section3/exercises/arrays.js @@ -24,42 +24,51 @@ console.log(animals[0]); // YOU DO: Write code below that will log the number of elements in array of // animals from above. - +console.log(animals.length); // YOU DO: Write code that will reassign the last item in the animals // array to "Gorilla" - +animals.splice(2, 1, 'Gorilla'); +console.log(animals); // YOU DO: Write code that will add a new animal (type of your choice) to position 3. - +animals.splice(2, 0, 'Panda'); +console.log(animals); // YOU DO: Write code that will log the String "Elephant" in the animals array - +animals.splice(3, 1, 'Elephant'); +console.log(animals[3]); //------------------- // PART 2: Foods: Array Methods //------------------- // YOU DO: Declare a variable that will store an an array of at least 4 foods (strings) - +var foods = ['Turnip', 'Egg', 'Steak']; // YOU DO: Write code below that will log the number of elements in the array of // foods from above. +console.log(foods.length); - -// YOU DO: Write code below that uses a method to add "broccoli" to the foods array and -// log the changed array to verify "broccoli" has been added - +// YOU DO: Write code below that uses a method to add "Broccoli" to the foods array and +// log the changed array to verify "Broccoli" has been added +foods.push('Broccoli'); +console.log(foods); // YOU DO: Write code below that removes the last item of food from the foods array and // log the changed array to verify that item has been removed +foods.pop(); +console.log(foods); - -// YOU DO: Write code to add 3 new foods to the array. +// YOU DO: Write code to add 3 new foods to the array. // There are several ways to do this - choose whichever you'd like! // Then, log the changed array to verify the new items have been added +foods.push('Bao buns', 'Cha Siu', 'Ha Gow'); +console.log(foods); // YOU DO: Remove the food that is in index position 0. +foods.splice(0, 1); +console.log(foods); //------------------- // PART 3: Where are Arrays used? @@ -79,12 +88,12 @@ The post itself likely has more complex data, but here's one way we can think ab var posts = ["image at beach", "holiday party", "adorable puppy", "video of cute baby"]; // YOU DO: Think of a web application you commonly use. Where do you see LISTS utilized, where arrays -// may be storing data? Come up with 3 examples - they could be from different web applications or +// may be storing data? Come up with 3 examples - they could be from different web applications or // all from the same one. -// 1: -// 2: -// 3: +// 1: Facebook - Friends request list +// 2: Instagram - follower list +// 3: Instagram - notifications //------------------- @@ -96,21 +105,40 @@ YOU DO: Using the variables defined below, write a program that will tell a user if they will be able to call an Uber. -The user can call an uber if they have 15% battery remaining, or more. In this case, it doesn't matter +The user can call an uber if they have 15% battery remaining, or more. In this case, it doesn't matter if the user has a charger at all, or what type. The can call an uber if they have a charger and it is a car charger. */ -var percentBatteryLeft = 12; -var hasCharger = true; -var chargerType = "car"; + // Write your conditional here +// Define value for variable percentBatteryLeft +var percentBatteryLeft = 16; +// Define value for variable hasCharger +var hasCharger = false; +// Define value for variable chargerType +var chargerType = "car"; +// Conditional statement, if percentBatteryLeft is greater than or equals to 15, the code +// directly under will be run. +if (percentBatteryLeft >= 15) { +// Log script "You can call an Uber!" to the console. + console.log("You can call an Uber!"); +// Conditional statement, if the if is not satisfied, and hasCharger equals true and chargerType equals +// "car", the code directly under will be run. +} else if ((hasCharger === true) && (chargerType === "car")) { +// Log script "You can call an Uber! But charge your phone." to the console. + console.log("You can call an Uber! But charge your phone."); +// Conditional statement, if the `if` and `else if` are not satisfied, the code directly under will be run. +} else { +// Log script "You're stranded. Better start walking!" to the console. + console.log("You're stranded. Better start walking!"); +} // YOU DO - ANNOTATE: Above each line of your code for this if statement, create a comment. // That comment should describe, in your own words, and as technically precise as possible, // what the line of code below, does. // MAKE 100% SURE that you have RUN the code in node in your command line, to ensure it works -// as you think it does🌟 \ No newline at end of file +// as you think it does🌟 diff --git a/section3/exercises/loops-arrays.js b/section3/exercises/loops-arrays.js index 33f88187a..6e8efe9cf 100644 --- a/section3/exercises/loops-arrays.js +++ b/section3/exercises/loops-arrays.js @@ -18,22 +18,37 @@ for (var i = 0; i < animals.length; i++) { // YOU DO: Write code below that iterates through a list of animals and prints "The // is awesome!" for each animal. +var animals = ["Alligator", "Lizard", "Mosquito"]; +for (var i = 0; i < animals.length; i++) { + console.log("The " + animals[i] + " is awesome!"); +} // YOU DO: Create an array of foods and then iterate over that array to log "Add // to shopping list" for each food item. +var shoppingList = ["Bread Crumbs", "Grated Parmesan Cheese", "Dijon Mustard", "Dave's Rub", "Eggs", "Pork Chops"]; +for (var i = 0; i < shoppingList.length; i++) { + console.log("Add " + shoppingList[i] + " to shopping list"); +} // YOU DO: Create an array of numbers and then iterate over that array to log double // of each of the number. (Ex: 4 doubled is 8.) +var hiTemps = [52, 70, 72]; +for (var i = 0; i < hiTemps.length; i++) { + console.log(2 * hiTemps[i]); +} // YOU DO: Using the array of names below, print out "Happy Birthday " for // each name except the first two. var names = ["Sevy", "Lindsey", "Jericho", "Raeonna", "Latrina", "Jhana", "Luca"]; +for (var i = 2; i < names.length; i++) { + console.log("Happy Birthday " + names[i]); +} // THE FINAL YOU DO: Using the array of ages below, print out a statement for each age. @@ -42,9 +57,16 @@ var names = ["Sevy", "Lindsey", "Jericho", "Raeonna", "Latrina", "Jhana", "Luca" // 18 or over? "Make sure you get out and vote!" // WORD FROM THE WISE: Before you start coding, jot down, with pen and paper, what steps you -// want to tell the program to take. Think of all the concepts you've learned so far. +// want to tell the program to take. Think of all the concepts you've learned so far. // Remember, stuck for 15-20 minutes? Reach out to your pre-work group on Slack. var ages = [17, 20, 34, 18, 16, 65, 49, 10, 22, 18]; +for (var i = 0; i < ages.length; i++) { + if (ages[i] >= 18) { + console.log("Make sure you get out and vote!"); + } else { + console.log("Oh no, you can't vote quite yet."); + } +} diff --git a/section3/exercises/loops.js b/section3/exercises/loops.js index f23beee43..2c6727765 100644 --- a/section3/exercises/loops.js +++ b/section3/exercises/loops.js @@ -23,24 +23,40 @@ for (var i = 0; i < 3; i++) { } // What is logged to the console for this second example? Why? -// EXPLAIN: +// EXPLAIN: It is logging i to the console 3 times. We start with i = 0, then we keep adding 1 to i every +// time the loop repeats itself by using i++. We tell the code to stop after the 3rd time with i < 3. +// Thus, the var i is logged to the console as 0, 1, 2 and the loop stops. // YOU DO: Write code below that logs to the console, the sum of 2 plus 2, 7 times: + var sum = 2 + 2; + for (var i = 0; i < 7; i++) { + console.log(sum); + } // YOU DO: Write code below that logs the String 'She sells seashells down by the seashore' // 10 times. + var sallySellsWhat = 'She sells seashells down by the seashore'; + for (var i = 0; i < 10; i++) { + console.log(sallySellsWhat); + } //------------------- // LEVEL 2: An Added Layer of Challenge //------------------- -// YOU DO: Write code below that logs to the console a String of "This is loop number: " +// YOU DO: Write code below that logs to the console a String of "This is loop number: " //that concatenates with `i`. +for (var i = 0; i < 3; i++) { + console.log("This is loop number: " + (i + 1)); +} // YOU DO: Using a for loop, how could you get an output that looks like this: +for (var i = 10; i > 0; i--) { + console.log(i); +} // 10 // 9 @@ -53,6 +69,6 @@ for (var i = 0; i < 3; i++) { // 2 // 1 -// Not sure? Try to google some terms that seem relevant. Play around with it. Don't spend +// Not sure? Try to google some terms that seem relevant. Play around with it. Don't spend // more than 15 minutes without making progress. If you are at 15 minutes and haven't made // progress, that means it's time to reach out to your pre-work group on Slack! diff --git a/section3/reflection.md b/section3/reflection.md index 8c3e6bcc5..368ebe55c 100644 --- a/section3/reflection.md +++ b/section3/reflection.md @@ -2,14 +2,31 @@ 1. What are two points from the Growth Mindset article and/or video that either resonated with you, or were brand new to you? +I resonated with "Mistakes are essential to learning". I really like the process of troubleshooting. "Zone of Proximal Development" is new to me, a zone where problem solving takes place within reach of current capability with some guidance. + 1. In which ways do you currently demonstrate a Growth Mindset? In which ways do you _not_? +I think I'm great at focusing on the process and realizing mistakes will be made along the way. I'm not so good at setting specific goals, but I usually give myself deadlines to complete work by and set aside the time. + 1. Think of a web or mobile application you use regularly. Where is an example of a place that the developers probably use Arrays? Explain. +Likes on Instagram. When you open it, you can see a list of users who liked the post. The users are the individual values within an array. + 1. In your own words, explain what an Array method is. +An array method is a function that we can apply to our array that can perform changes to text, order, and +perform calculations with numbers. + 1. What is the purpose of a loop? When we would use a loop in conjunction with array vs. without? +A loop performs the tasks within it a user-specified number of times. +With array, when we are trying to log certain parts of the array to the console by iteration. +Without array, when we are looking to count up and down numbers declared by var i. + 1. If you had to teach a 5 year old about loops, how would you explain it? -1. What questions do you still have about Arrays and loops? \ No newline at end of file +We're gonna make this robot dig up the yard until we find **treasure!** We're going to program it to dig and dump, over and over, until we get rich! + +1. What questions do you still have about Arrays and loops? + +What are more applications for these, and what are examples of loops with and without arrays on a website? From 626fb938e9680e8bc1dc5ac3e46e9c3035eada27 Mon Sep 17 00:00:00 2001 From: Eric Li Date: Wed, 31 Mar 2021 17:08:12 -0600 Subject: [PATCH 05/10] Add Section 4 --- section4/exercises/classMethods.js | 32 ++++++-- section4/exercises/classProperties.js | 113 +++++++++++++++++++++++++- section4/exercises/methods.js | 15 +++- section4/exercises/objects.js | 72 ++++++++++++---- section4/exercises/tweet.js | 25 +++++- section4/reflection.md | 35 +++++--- 6 files changed, 256 insertions(+), 36 deletions(-) diff --git a/section4/exercises/classMethods.js b/section4/exercises/classMethods.js index 58e6e82f0..8152c7ccc 100644 --- a/section4/exercises/classMethods.js +++ b/section4/exercises/classMethods.js @@ -7,17 +7,17 @@ Complete each task, using the Burrito class below as a starting point. Make sure to run the file with node in your command line. */ -// The burrito should also have a property called `toppings`. It should be assigned to +// The burrito should also have a property called `toppings`. It should be assigned to // the toppings parameter in the constructor. -// Below/outside of the class declaration, create 3 object instances of a burrito. +// Below/outside of the class declaration, create 3 object instances of a burrito. // The toppings argument should be an Array of Strings. -// The burrito class should have a method named `changeProtein`. +// The burrito class should have a method named `changeProtein`. // This method should accept one argument, a String. // The method should re-assign this.protein to the value that was passed in. -// Call the `changeProtein` method on a burrito, then log the burrito to verify +// Call the `changeProtein` method on a burrito, then log the burrito to verify // that the protein has been changed. // The burrito class should have a method named `addTopping`. @@ -28,13 +28,33 @@ Make sure to run the file with node in your command line. // that the proteins have been changed. class Burrito { - constructor(protein, base) { + constructor(protein, base, toppings) { this.protein = protein; this.base = base; + this.toppings = toppings; + } + changeProtein() { + this.protein = "Tofu"; + } addTopping() { + this.toppings.unshift("Sour Cream"); } - // ADD CODE }; +var ericsBurrito = new Burrito("Steak", "White Rice", ["beans", "pico", "cheese", "peppers"]); +console.log(ericsBurrito); + +var ryansBurrito = new Burrito("Tofu", "Brown Rice", ["beans", "pico", "kale", "quinoa"]); +console.log(ryansBurrito); + +var matheusBurrito = new Burrito("Carnitas", "White Rice", ["guacamole", "pico", "cheese", "peppers"]); +console.log(matheusBurrito); // ADD CODE +ericsBurrito.changeProtein(); +console.log(ericsBurrito); + +ryansBurrito.addTopping(); +console.log(ryansBurrito); +matheusBurrito.addTopping(); +console.log(matheusBurrito); diff --git a/section4/exercises/classProperties.js b/section4/exercises/classProperties.js index aec49cfb8..2245f459f 100644 --- a/section4/exercises/classProperties.js +++ b/section4/exercises/classProperties.js @@ -16,11 +16,43 @@ Make sure to run the file with node in your command line. // You do not need any proerties at this time!! // Prompt 1: Dog +// I'm unsure if I accurately answered this section. I'm wondering +// if the variables cloud and flash are supposed to be logged instead of +// the class, Dog, twice. + +class Dog { +} + +var cloud = new Dog(); +console.log(cloud); + +var flash = new Dog(); +console.log(flash); + // Prompt 2: Snack +class Snack { +} + +var empanada = new Snack(); +console.log(empanada); + +var quesito = new Snack(); +console.log(quesito); + + // Prompt 3: Shirt +class Shirt { +} + +var barong = new Shirt(); +console.log(barong); + +var aoDai = new Shirt(); +console.log(aoDai); + //------------------- // Part 2: Properties //------------------- @@ -34,10 +66,45 @@ Make sure to run the file with node in your command line. // Prompt 1: Dog +class Dog1 { + constructor() { + this.name = "cloud"; + this.age = 6; + this.complexion = "black and white"; + } +} + +var cloud = new Dog1(); +console.log(cloud); + // Prompt 2: Snack +class Snack1 { + constructor() { + this.name = "empanada"; + this.taste = "beef"; + this.temperature = "hot"; + } +} + +var empanada = new Snack1(); +console.log(empanada); + + // Prompt 3: Shirt +class Shirt1 { + constructor() { + this.name = "Ao Dai"; + this.countryOfOrigin = "Vietnam"; + this.construction = "Silk"; + } +} + +var aoDai = new Shirt1(); +console.log(aoDai); + + //------------------- // Part 3: Dynamic Properties //------------------- @@ -52,6 +119,50 @@ Make sure to run the file with node in your command line. // Prompt 1: Dog +class Dog2 { + constructor(name, age, color) { + this.name = name; + this.age = age; + this.complexion = color; + } +} + +var cloud = new Dog2("Cloud", 6, "black and white"); +console.log(cloud); + +var flash = new Dog2("Flash,", 3, "white"); +console.log(flash); + + // Prompt 2: Snack -// Prompt 3: Shirt \ No newline at end of file +class Snack2 { + constructor(name, flavor, temperature) { + this.name = name; + this.taste = flavor; + this.temperature = temperature; + } +} + +var empanada = new Snack2("empanada", "beef", "hot"); +console.log(empanada); + +var quesito = new Snack2("quesito", "sweet", "warm"); +console.log(quesito); + + +// Prompt 3: Shirt + +class Shirt2 { + constructor(name, origin, material) { + this.name = name; + this.countryOfOrigin = origin; + this.construction = material; + } +} + +var aoDai = new Shirt2("Ao Dai", "Vietnam", "Silk"); +console.log(aoDai); + +var barong = new Shirt2("Barong", "Philippines", ["cotton", "piña", "silk"]); +console.log(barong); diff --git a/section4/exercises/methods.js b/section4/exercises/methods.js index 20bdfc2e1..2d58c41a6 100644 --- a/section4/exercises/methods.js +++ b/section4/exercises/methods.js @@ -16,5 +16,16 @@ Make sure to run the file with node in your command line. var lunchOrder = { dish: "BLT", beverage: "iced tea", - tableNumber: 47 -} \ No newline at end of file + tableNumber: 47, + prepare: function() { + console.log("Burger King is preparing your order.") + }, + complete: function() { + console.log("Your order is ready!") + } +}; + +console.log(lunchOrder); + +lunchOrder.prepare(); +lunchOrder.complete(); diff --git a/section4/exercises/objects.js b/section4/exercises/objects.js index e1ef583bf..58edb3f71 100644 --- a/section4/exercises/objects.js +++ b/section4/exercises/objects.js @@ -8,7 +8,7 @@ any remaining prompt. Make sure to run the file with node in your command line. */ -// EXAMPLE: Write code below that will declare a vairable that stores an Object Literal +// EXAMPLE: Write code below that will declare a variable that stores an Object Literal // that holds grocery store inventory var foods = { apples: 23, @@ -17,30 +17,38 @@ var foods = { }; console.log(foods); -// Notice that the variable name is foods, plural, because it has the ability to hold info about -// potentially many foods. That plural name indicates to another developer that the variable stores +// Notice that the variable name is foods, plural, because it has the ability to hold info about +// potentially many foods. That plural name indicates to another developer that the variable stores // either an Array or an Object. //------------------- // Part 1: Zoo Animals //------------------- -// YOU DO: Write code below that will declare a variable that stores an Object Literal of animal names and +// YOU DO: Write code below that will declare a variable that stores an Object Literal of animal names and // the number of that type of animal at the zoo. +var animalQuantity = { + rhinos: 20, + giraffes: 3, + tigers: 1 +}; // Using the zoo that you created above, log the value of the first item in // the Object - +console.log(animalQuantity.rhinos); // Add an animal to the zoo Object, and log the updated Object. - +animalQuantity['elephants'] = 5; +console.log(animalQuantity.elephants); // Change the value for at least one of your animal keys, and log the updated Object. - +animalQuantity['giraffes'] = 4; +console.log(animalQuantity.giraffes); // Add another animal to the zoo Object, and log the updated Object. - +animalQuantity['geese'] = 25; +console.log(animalQuantity); //------------------- // Part 2: Email @@ -55,6 +63,15 @@ value should be some appropriate value for that key. Work to have at least 5 key Log your email object to the console. */ +var contactInfo = { + firstName: "Eric", + lastName: "Li", + dateOfBirth: "July 20", + emailAddress: "ericli@knights.ucf.edu", + phoneNumber: "123-456-7890" +}; + +console.log(contactInfo); //------------------- // Part 3: Many Emails - OPTIONAL EXTENSION @@ -70,7 +87,7 @@ In the arrays exercise, we gave the following example of an array of Instagram p var posts = ["image at beach", "holiday party", "adorable puppy", "video of cute baby"]; /* -Frankly, that was a very simplified version of the Array the Instagram developers have +Frankly, that was a very simplified version of the Array the Instagram developers have written and work with. Still probably slightly simplified as we don't know what their code actually looks like, but it may look more like this: */ @@ -82,7 +99,7 @@ var posts = [ timeStamp: "4:37 PM August 13, 2019", numberLikes: 0, comments: [] - }, + }, { imageSrc: "./images/holiday-party.png", caption: "What a great holiday party omg", @@ -96,12 +113,39 @@ console.log(posts); console.log(posts[0]); /* -The code snippet above shows an Array with 2 elements. Each element in an -Object Literal. Each of those Object Literals has 4 key-value pairs. This may LOOK +The code snippet above shows an Array with 2 elements. Each element in an +Object Literal. Each of those Object Literals has 4 key-value pairs. This may LOOK a bit daunting - it's OK! You don't need to be 100% comfortable with this, but it's good to have some exposure before going into Mod 1. */ -// YOU DO: Create an array of at least 3 EMAIL Object Literals, using the same +// YOU DO: Create an array of at least 3 EMAIL Object Literals, using the same // key-value pairs you used in your email Object above. -// Then, log the email Array to the console. \ No newline at end of file +// Then, log the email Array to the console. + +var contactInfo = [ + { + firstName: "Eric", + lastName: "Li", + dateOfBirth: "July 20", + emailAddress: "ericli@knights.ucf.edu", + phoneNumber: "123-456-7890" + }, + { + firstName: "Dave", + lastName: "Anderson", + dateOfBirth: "June 6", + emailAddress: "danderson@hotmail.com", + phoneNumber: "123-456-7891" + }, + { + firstName: "Larry", + lastName: "Saunders", + dateOfBirth: "December 7", + emailAddress: "happysaunders@yahoo.com", + phoneNumber: "123-456-7892" + } +] + +console.log(contactInfo); +console.log(contactInfo[0]); diff --git a/section4/exercises/tweet.js b/section4/exercises/tweet.js index 272700a87..424ef5d61 100644 --- a/section4/exercises/tweet.js +++ b/section4/exercises/tweet.js @@ -9,5 +9,28 @@ tweet object instances _behave_ as expected. */ class Tweet { + constructor(author, content, timeStamp, numberOfLikes, comments) { + this.author = author; + this.content = content; + this.timePosted = timeStamp; + this.likes = numberOfLikes; + this.comments = comments; + } -}; \ No newline at end of file + addLikes() { + this.likes = this.likes + 1; + } addComments(x) { + this.comments.unshift(x); + } +}; + +var firstTweet = new Tweet("Eric Li", "Hello World", "3:13PM", 26, ["Wow!", "So Cool!", "I wish I was you."]); +console.log(firstTweet); + +var firstTweet = new Tweet("Larry Saunders", "Goodbye World", "3:15PM", 35, ["Wow!", "So Cool!", "I wish I was you."]); +firstTweet.addLikes(); +console.log(firstTweet); + +var firstTweet = new Tweet("Barry Vasquez", "Hello World", "3:17PM", 51, ["Wow!", "So Cool!", "I wish I was you."]); +firstTweet.addComments("Dat Boi"); +console.log(firstTweet); diff --git a/section4/reflection.md b/section4/reflection.md index 2eed64a15..95e74e244 100644 --- a/section4/reflection.md +++ b/section4/reflection.md @@ -2,20 +2,31 @@ 1. How different did your workflow feel this week, considering we asked you to follow the Pomodoro technique? -1. Regarding the work you did around setting intentions in Step 1 of the Pomodoro technique - how did that go? Were you surprised by anything (did you find yourself way more focused than you realized, more distracted that you thought you'd be, estimating times accurately or totally off, etc)? + It helped my work feel more focused and efficient. During the times I set aside to put in work, I was more deliberate with making progress. -1. What is an Object, and how is it different from an Array in Javascript? +2. Regarding the work you did around setting intentions in Step 1 of the Pomodoro technique - how did that go? Were you surprised by anything (did you find yourself way more focused than you realized, more distracted that you thought you'd be, estimating times accurately or totally off, etc)? -1. For each set of data, would an array or object be better to store it? Explain your choice. + I thought I was more focused! I would like to try using a mechanical timer, so I get the added pressure of the ticking sound counting down the allotted time. - * List of all of the students in class - * List of states and their capitals - * List of things to pack for vacation - * Names of all the Instagram accounts I follow - * List of student names and their cohort - * Ingredients and amount of each ingredient to bake a cake - * All my favorite restaurants +3. What is an Object, and how is it different from an Array in Javascript? -1. In this section, we talked about an `transaction item object`. It has keys that represent different properties an bank transaction would have, and values that store the data. In a banking app, this data would eventually be displayed in the browser for the user. Think of another Object in a web application that you use frequently. What is it? What keys might be on it? What are example values? + An object is something that has individual properties and can have methods as well. In addition, objects contain arrays of properties. An array is an ordered list of values. -1. What questions do you still have about classes and/or Objects? +4. For each set of data, would an array or object be better to store it? Explain your choice. + + * List of all of the students in class _array_ + * List of states and their capitals _object_ + * List of things to pack for vacation _array_ + * Names of all the Instagram accounts I follow _array_ + * List of student names and their cohort _object_ + * Ingredients and amount of each ingredient to bake a cake _object_ + * All my favorite restaurants _array_ + +5. In this section, we talked about an `transaction item object`. It has keys that represent different properties an bank transaction would have, and values that store the data. In a banking app, this data would eventually be displayed in the browser for the user. Think of another Object in a web application that you use frequently. What is it? What keys might be on it? What are example values? + + Example: Facebook + User Profile: keys might be username, emailAddress, while values might look like "ericli1996" or "ericli@knights.ucf.edu" + +6. What questions do you still have about classes and/or Objects? + + I would like to better grasp the syntax for different things I can do with an Object Method. From 2ac0028f8431988d4ca3a8e853cca2678205096e Mon Sep 17 00:00:00 2001 From: Eric Li Date: Fri, 2 Apr 2021 18:27:34 -0600 Subject: [PATCH 06/10] Refactor Section 2 exercises --- section2/exercises/decision-making.js | 2 +- section2/exercises/if-statements.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/section2/exercises/decision-making.js b/section2/exercises/decision-making.js index 75cd770c2..e5f2e8428 100644 --- a/section2/exercises/decision-making.js +++ b/section2/exercises/decision-making.js @@ -44,7 +44,7 @@ Questions In this case, we are using the comparison operator === to indicate the condition will result in true if the variable bearChoice is exactly equals to 1. - Any value other than 1 will result in a false. If the condition is met, or if variable bearClothing changes to "hat". If the + Any value other than 1 will result in a false. If the condition is met, or true, variable bearClothing changes to "hat". If the condition is not met, or else, the variable bearClothing changes to "shirt". 2. What variable has a new value assigned to it after the first if statement executes? diff --git a/section2/exercises/if-statements.js b/section2/exercises/if-statements.js index 51b4ab956..601e024a4 100644 --- a/section2/exercises/if-statements.js +++ b/section2/exercises/if-statements.js @@ -97,7 +97,7 @@ When cupsOfFlour = 3 and hasSauce = true, your program should log "I can make pi */ var cupsOfFlour = 2; -var hasSauce = false; +var hasSauce = true; // Write your conditional here if (cupsOfFlour >= 2 && hasSauce === true) { From 3e2e75a46c6bf76687e973a425e8eda28b4a84e4 Mon Sep 17 00:00:00 2001 From: Eric Li Date: Fri, 2 Apr 2021 18:43:30 -0600 Subject: [PATCH 07/10] Refactor Section 3 exercises --- section3/exercises/arrays.js | 6 +++--- section3/exercises/loops.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/section3/exercises/arrays.js b/section3/exercises/arrays.js index cddfdf022..140003acc 100644 --- a/section3/exercises/arrays.js +++ b/section3/exercises/arrays.js @@ -32,7 +32,7 @@ animals.splice(2, 1, 'Gorilla'); console.log(animals); // YOU DO: Write code that will add a new animal (type of your choice) to position 3. -animals.splice(2, 0, 'Panda'); +animals.splice(3, 0, 'Panda'); console.log(animals); // YOU DO: Write code that will log the String "Elephant" in the animals array @@ -44,7 +44,7 @@ console.log(animals[3]); //------------------- // YOU DO: Declare a variable that will store an an array of at least 4 foods (strings) -var foods = ['Turnip', 'Egg', 'Steak']; +var foods = ['Turnip', 'Egg', 'Steak', 'Eggplant']; // YOU DO: Write code below that will log the number of elements in the array of // foods from above. @@ -127,7 +127,7 @@ if (percentBatteryLeft >= 15) { console.log("You can call an Uber!"); // Conditional statement, if the if is not satisfied, and hasCharger equals true and chargerType equals // "car", the code directly under will be run. -} else if ((hasCharger === true) && (chargerType === "car")) { +} else if (hasCharger === true && chargerType === "car") { // Log script "You can call an Uber! But charge your phone." to the console. console.log("You can call an Uber! But charge your phone."); // Conditional statement, if the `if` and `else if` are not satisfied, the code directly under will be run. diff --git a/section3/exercises/loops.js b/section3/exercises/loops.js index 2c6727765..07a4e24ad 100644 --- a/section3/exercises/loops.js +++ b/section3/exercises/loops.js @@ -23,9 +23,9 @@ for (var i = 0; i < 3; i++) { } // What is logged to the console for this second example? Why? -// EXPLAIN: It is logging i to the console 3 times. We start with i = 0, then we keep adding 1 to i every -// time the loop repeats itself by using i++. We tell the code to stop after the 3rd time with i < 3. -// Thus, the var i is logged to the console as 0, 1, 2 and the loop stops. +// EXPLAIN: It is logging i, or index position, to the console 3 times. We start with i = 0, then we +// keep adding 1 to i every time the loop repeats itself by using i++. We tell the code to stop after +// the 3rd time with i < 3. Thus, the var i is logged to the console as 0, 1, 2 and the loop stops. // YOU DO: Write code below that logs to the console, the sum of 2 plus 2, 7 times: From 1b4fd0d495ab088f202ece1d16d08c9f7260de14 Mon Sep 17 00:00:00 2001 From: Eric Li Date: Mon, 5 Apr 2021 16:51:20 -0600 Subject: [PATCH 08/10] Refactor Section 4 exercises --- section4/exercises/classProperties.js | 10 +++++----- section4/exercises/objects.js | 3 +-- section4/exercises/tweet.js | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/section4/exercises/classProperties.js b/section4/exercises/classProperties.js index 2245f459f..36e1c1f09 100644 --- a/section4/exercises/classProperties.js +++ b/section4/exercises/classProperties.js @@ -80,14 +80,14 @@ console.log(cloud); // Prompt 2: Snack class Snack1 { - constructor() { - this.name = "empanada"; - this.taste = "beef"; - this.temperature = "hot"; + constructor(name, flavor, temp) { + this.name = name; + this.taste = flavor; + this.temperature = temp; } } -var empanada = new Snack1(); +var empanada = new Snack1("empanada", "beef", "hot"); console.log(empanada); diff --git a/section4/exercises/objects.js b/section4/exercises/objects.js index 58edb3f71..8ed06fae6 100644 --- a/section4/exercises/objects.js +++ b/section4/exercises/objects.js @@ -40,7 +40,7 @@ console.log(animalQuantity.rhinos); // Add an animal to the zoo Object, and log the updated Object. animalQuantity['elephants'] = 5; -console.log(animalQuantity.elephants); +console.log(animalQuantity); // Change the value for at least one of your animal keys, and log the updated Object. animalQuantity['giraffes'] = 4; @@ -148,4 +148,3 @@ var contactInfo = [ ] console.log(contactInfo); -console.log(contactInfo[0]); diff --git a/section4/exercises/tweet.js b/section4/exercises/tweet.js index 424ef5d61..63f60730c 100644 --- a/section4/exercises/tweet.js +++ b/section4/exercises/tweet.js @@ -19,8 +19,8 @@ class Tweet { addLikes() { this.likes = this.likes + 1; - } addComments(x) { - this.comments.unshift(x); + } addComments(comment) { + this.comments.unshift(comment); } }; From f5bd923fe07e5d81411c60b21f347d87b2af3d8c Mon Sep 17 00:00:00 2001 From: Eric Li <75854628+ericli1996@users.noreply.github.com> Date: Mon, 5 Apr 2021 16:56:01 -0600 Subject: [PATCH 09/10] Update README.md --- finalPrep/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/finalPrep/README.md b/finalPrep/README.md index 08301c72c..186b8100f 100644 --- a/finalPrep/README.md +++ b/finalPrep/README.md @@ -18,10 +18,10 @@ Some things to consider as you refactor include... Take your time as you go back and refactor your exercises from each section. We've included a handy checklist for you to go through below. -- [ ] I have refactored my `section1` exercises to the best of my ability -- [ ] I have refactored my `section2` exercises to the best of my ability -- [ ] I have refactored my `section3` exercises to the best of my ability -- [ ] I have refactored my `section4` exercises to the best of my ability +- [x] I have refactored my `section1` exercises to the best of my ability +- [x] I have refactored my `section2` exercises to the best of my ability +- [x] I have refactored my `section3` exercises to the best of my ability +- [x] I have refactored my `section4` exercises to the best of my ability ### Time Management Prep In Mod 0 you've learned about different techniques for managing your time at Turing. Please create a calendar for your **first 3 weeks of Mod 1**. Feel free to make your calendar fit your style, but we suggest that your calendar should include the following: From 2fa82474f933968eedbf9836cf6333cfe337d2ea Mon Sep 17 00:00:00 2001 From: Eric Li Date: Sat, 10 Apr 2021 13:06:40 -0600 Subject: [PATCH 10/10] Add finalPrep work --- finalPrep/README.md | 33 +++++++------- finalPrep/annotations.js | 33 ++++++++++++-- finalPrep/modZeroHero.js | 94 ++++++++++++++++++++++++++++++++++++---- 3 files changed, 130 insertions(+), 30 deletions(-) diff --git a/finalPrep/README.md b/finalPrep/README.md index 186b8100f..72829b3a5 100644 --- a/finalPrep/README.md +++ b/finalPrep/README.md @@ -2,13 +2,13 @@ Congrats on making it to the Mod 0 Final Prep! Complete the final exercises below and be sure to carefully follow the Pull Request steps to submit your work! ### Final Technical Prep -You've learned a ton about some of the core foundations of Javascript! Show us how far you've come by completing the following exercises! You will be using your work from these exercises in your first day of Mod 1! +You've learned a ton about some of the core foundations of Javascript! Show us how far you've come by completing the following exercises! You will be using your work from these exercises in your first day of Mod 1! -- [ ] Complete the [Mod Zero Hero Challenge](./modZeroHero.js) -- [ ] Complete the [Annotation Challenge](./annotations.js) +- [x] Complete the [Mod Zero Hero Challenge](./modZeroHero.js) +- [x] Complete the [Annotation Challenge](./annotations.js) ### Refactor Previous Work -You've learned A LOT over the last few weeks as it relates to technical content - chances are, you probably have some code from your previous exercises that is either sloppy, incorrect, poorly named, etc. Before starting Mod 1, we want you to `refactor` your code - which is the process of adjusting or improving your code for readability and accuracy. +You've learned A LOT over the last few weeks as it relates to technical content - chances are, you probably have some code from your previous exercises that is either sloppy, incorrect, poorly named, etc. Before starting Mod 1, we want you to `refactor` your code - which is the process of adjusting or improving your code for readability and accuracy. Some things to consider as you refactor include... - Are my variable names easy to understand/convey the data type they are assigned to? @@ -25,30 +25,30 @@ Take your time as you go back and refactor your exercises from each section. We' ### Time Management Prep In Mod 0 you've learned about different techniques for managing your time at Turing. Please create a calendar for your **first 3 weeks of Mod 1**. Feel free to make your calendar fit your style, but we suggest that your calendar should include the following: -- [ ] Standard M1 class schedule (see M1 calendar [here](https://frontend.turing.io/today/)) -- [ ] Study/Project work time -- [ ] Health + Wellness +- [x] Standard M1 class schedule (see M1 calendar [here](https://frontend.turing.io/today/)) +- [x] Study/Project work time +- [x] Health + Wellness When you are finished, add screenshots of your calendar so we can provide feedback if needed! -- `Add Week 1 Screenshot Here` -- `Add Week 2 Screenshot Here` -- `Add Week 3 Screenshot Here` +- [Week One](https://user-images.githubusercontent.com/75854628/113923931-646a8580-97a6-11eb-8cd0-31dc80af1f22.png) +- [Week Two](https://user-images.githubusercontent.com/75854628/113924108-a693c700-97a6-11eb-910a-9c20a69d36dc.png) +- [Week Three](https://user-images.githubusercontent.com/75854628/113924198-c0cda500-97a6-11eb-96c5-36f49a2b56a9.png) ### Mentorship Prep Mentorship is an integral part of the Turing experience and will help jumpstart your technical career. In order to get your mentor relationship started on the right foot, please complete the following deliverables: -- [ ] Complete the [Mentorship DTR Prep](https://gist.github.com/ericweissman/51965bdcbf42970d43d817818bfaef3c) - - [ ] Add link to your gist here: +- [x] Complete the [Mentorship DTR Prep](https://gist.github.com/ericweissman/51965bdcbf42970d43d817818bfaef3c) + - [x] Add link to your gist here: [Mentorship DTR Gist](https://gist.github.com/ericli1996/4a4c85f8699399d7f2daa243419eb807) ### Lesson Prep You've learned a lot about how to take strong notes during Mod 0. Show us your skills while you learn how to pre-teach content for your first lesson in Mod 1! -- [ ] Complete the [Pre Teaching Practice exercise](https://gist.github.com/ericweissman/0036e8fe272c02bd6d4bb14f42fd2f79) gist - - [ ] Add a link to your gist here: +- [x] Complete the [Pre Teaching Practice exercise](https://gist.github.com/ericweissman/0036e8fe272c02bd6d4bb14f42fd2f79) gist + - [x] Add a link to your gist here: [Pre Teaching Practice](https://gist.github.com/ericli1996/abffad351c4dc443e4aff0b8be144721) ### Group Work Prep As part of Turing's project-based learning approach, you will often be working in pairs or larger groups. In order to set yourself (and your team) up for success, it is important to ensure you are prepared to be an equitable contributor and teammate. -- [ ] Complete the [DTR Guiding Questions](https://gist.github.com/ericweissman/c56f3a98cdce761808c21d498a52f5c6) - - [ ] Add a link to your gist here: +- [x] Complete the [DTR Guiding Questions](https://gist.github.com/ericweissman/c56f3a98cdce761808c21d498a52f5c6) + - [x] Add a link to your gist here:[DTR Guiding Questions](https://gist.github.com/ericli1996/7fafc1709a5033d716a6ccb354a249ef) ## All Done? How to Submit your M1 Prework When you have completed *ALL* the activities described above, follow the steps below to submit your technical prework. @@ -86,4 +86,3 @@ What is your plan and how are you going to hold yourself to it? Specifically... ## Extensions If you're interested in challenging yourself _even more_ and getting a step ahead in your coding abilities before your first day, we recommend working on either: - diff --git a/finalPrep/annotations.js b/finalPrep/annotations.js index e49759ec6..c825cc9b2 100644 --- a/finalPrep/annotations.js +++ b/finalPrep/annotations.js @@ -2,41 +2,66 @@ // Use the double // to create a new comment //Build a Bear +// Declare function buildABear and list some parameters. function buildABear(name, age, fur, clothes, specialPower) { + // Declare variable greeting and assign it to a string with variable name interpolated into it. var greeting = `Hey partner! My name is ${name} - will you be my friend?!`; + // Declare variable demographics and assign it to an array of variables. var demographics = [name, age]; + // Declare variable powerSaying and assign it to a string that uses concatenation and the + // variable specialPower. var powerSaying = "Did you know that I can " + specialPower + " ?"; + // Declare variable builtBear and assign it to an object, with properties. var builtBear = { + // These first three properties are dynamic. basicInfo: demographics, clothes: clothes, exterior: fur, + // This property is assigned to an integer. cost: 49.99, + // This property is assigned to an array of variables and a string. sayings: [greeting, powerSaying, "Goodnight my friend!"], + // This property is assigned to a boolean value. isCuddly: true, }; - + // Return the builtBear object to the caller. return builtBear } - +// Call function to build a bear with the following properties in the parentheses. buildABear('Fluffy', 4, 'brown', ['pants', 'jorts', 'tanktop'], 'give you nightmares'); +// Call function to build a bear with the following properties in the parentheses. buildABear('Sleepy', 2, 'purple', ['pajamas', 'sleeping cap'], 'sleeping in'); //FizzBuzz +// Declare function fizzBuzz and give it some parameters. function fizzBuzz(num1, num2, range) { + // Declare a loop, with the counter starting at 0 and going up by one until i is greater + // than the value for range. for (var i = 0; i <= range; i++) { + // Declare an if statement, if modulo of i into num1 AND the modulo of i into num2 is + // both 0, then... if (i % num1 === 0 && i % num2 === 0) { + // Log the string 'fizzbuzz' to the console. console.log('fizzbuzz'); + // If the above is not satisfied, and the modulo of i into num1 is equal to 0, then... } else if (i % num1 === 0) { + // Log the string 'fizz' to the console. console.log('fizz'); + // If the above condition is not satisfied, and the modulo of i into num2 is equal to + // 0, then... } else if (i % num2 === 0) { + // Log the string 'buzz' to the console. console.log('buzz'); + // If all of the above conditions are not satisfied, then... } else { + // Log the value of i to the console. console.log(i); } } } - +// Call the function fizzBuzz with num1 = 3, num2 = 5, and range = 100. fizzBuzz(3, 5, 100); -fizzbuzz(5, 8, 400); \ No newline at end of file +// Call the function fizzBuzz with num1 = 5, num2 = 8, and range = 400. +fizzBuzz(5, 8, 400); diff --git a/finalPrep/modZeroHero.js b/finalPrep/modZeroHero.js index 1ba2a8ac1..4bfde28c3 100644 --- a/finalPrep/modZeroHero.js +++ b/finalPrep/modZeroHero.js @@ -1,49 +1,80 @@ // Challenge - See if you can follow the instructions and complete the exercise in under 30 minutes! // Declare two variables - heroName AND specialAbility - set to strings +var heroName = "Johnny Bravo"; +var specialAbility = "Being Cool"; // Declare two variables - greeting AND catchphrase // greeting should be assigned to a string that uses concatenation to include the heroName // catchphrase should be assigned to a string that uses interpolation to include the specialAbility +var greeting = "Hi, I'm " + heroName; +var catchphrase = `My super power is ${specialAbility}`; // Declare two variables - power AND energy - set to integers +var power = 240; +var energy = 100; // Declare two variables - fullPower AND fullEnergy // fullPower should multiply your current power by 500 // fullEnergy should add 150 to your current energy +var fullPower = power * 500; +var fullEnergy = energy + 150; // Declare two variables - isHuman and identityConcealed - assigned to booleans - +var isHuman = true; +var identityConcealed = false; // Declare two variables - archEnemies AND sidekicks // archEnemies should be an array of at least 3 different enemy strings // sidekicks should be an array of at least 3 different sidekick strings +var archEnemies = ["Kevin", "Larry", "Popeye"]; +var sidekicks = ["Carl", "Pops", "Little Suzy"]; // Print the first sidekick to your console +console.log(sidekicks[0]); // Print the last archEnemy to the console +console.log(archEnemies[2]); // Write some code to add a new archEnemy to the archEnemies array +archEnemies.splice(3, 0, "Wanda"); // Print the archEnemies array to console to ensure you added a new archEnemy +console.log(archEnemies); // Remove the first sidekick from the sidekicks array +sidekicks.shift(); // Print the sidekicks array to console to ensure you added a new sidekick +sidekicks.splice(0, 0, "Carl Jr."); +console.log(sidekicks); // Create a function called assessSituation that takes three arguments - dangerLevel, saveTheDay, badExcuse // - dangerLevel should be an integer -// - saveTheDay should be a string a hero would say once they save the day +// - saveTheDay should be a string a hero would say once they save the day // - badExcuse should be a string a hero would say if they are too afraid of the dangerLevel // Your function should include an if/else statement that meets the following criteria // - Danger levels that are above 50 are too scary for your hero. Any danger level that is above 50 should result in printing the badExcuse to the console // - Anything dangerLevel that is between 10 and 50 should result in printing the saveTheDay string to the console // - If the dangerLevel is below 10, it means it is not worth your time and should result in printing the string "Meh. Hard pass." to the console. - +var dangerLevel; +var announcement = 'Never fear, the Courageous Birdman is here!'; +var excuse = 'I have to go ask my wife. Be right back.'; + +function assessSituation(dangerLevel, announcement, excuse) { + if (dangerLevel < 10) { + console.log('Meh. Hard pass.'); + } else if (dangerLevel <= 50) { + console.log(announcement); + } else { + console.log(excuse); + } +} + +assessSituation(49, announcement, excuse); //Test Cases -var announcement = 'Never fear, the Courageous Curly Bracket is here!'; -var excuse = 'I think I forgot to lock up my 1992 Toyota Coralla. Be right back.'; + // assessSituation(99, announcement, excuse) > Should print - 'I think I forgot to lock up my 1992 Toyota Coralla. Be right back.' //assessSituation(21, announcement, excuse) > should print - 'Never fear, the Courageous Curly Bracket is here!' //assessSituation(3, announcement, excuse) > should print - "Meh. Hard pass." @@ -55,17 +86,47 @@ var excuse = 'I think I forgot to lock up my 1992 Toyota Coralla. Be right back. // - citiesDestroyed (array) // - luckyNumbers (array) // - address (object with following key/values: number , street , state, zip) +var scaryMonster = { + name: "Godzilla", + smell: "Sulfur", + weightInTons: 99634, + citiesDestroyed: ["Tokyo", "New York City", "Fukuoka"], + luckyNumbers: [666, 13, 4], + address: { + number: 123, + street: "Pacific Ocean Way", + state: "Pacifica", + zip: 66666 + } +} // Create a new class called SuperHero // - Your class should have the following DYNAMIC values -// - name +// - name // - superpower -// - age +// - age // - Your class should have the following STATIC values // - archNemesis, assigned to "The Syntax Error" // - powerLevel = 100 -// - energyLevel = 50 +// - energyLevel = 50 +class SuperHero { + constructor(name, superpower, ageInYears) { + this.name = name; + this.superpower = superpower; + this.age = ageInYears; + this.archNemesis = "The Syntax Error"; + this.powerLevel = 100; + this.energyLevel = 50 + } + sayName() { + console.log(this.name); + } maximizeEnergy() { + this.energyLevel = 1000; + } gainPower(x) { + this.powerLevel = this.powerLevel + x; + } +} // - Create the following class methods // - sayName, should print the hero's name to the console @@ -73,12 +134,27 @@ var excuse = 'I think I forgot to lock up my 1992 Toyota Coralla. Be right back. // - gainPower, should take an argument of a number and INCREASE the powerLevel by that number // - Create 2 instances of your SuperHero class +var ericHero = new SuperHero("Eric", "Sleeping", 24); +ericHero.sayName(); +ericHero.gainPower(25000); +console.log(ericHero); + +var ryanHero = new SuperHero("Ryan", "Gaming", 25); +ryanHero.maximizeEnergy(); +console.log(ryanHero); // Reflection // What parts were most difficult about this exerise? +// I think the most difficult parts were remembering the correct syntax to use between similar +// concepts, like objects and classes. Also it was interesting that I could put an object within +// an object, so I would like to learn more about the different limitations and applications. // What parts felt most comfortable to you? +// Naming variables, as well as strings, interpolation, declaring a function, is pretty cake. +// I understand if statements, classes, and objects somewhat well, but I have to go back and +// check that I'm using the proper syntax. // What skills do you need to continue to practice before starting Mod 1? - +// Syntax, syntax, syntax. I would also like to better understand classes and constructor +// statements.