Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Casey Halstead #200

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Add Section 2 work
  • Loading branch information
chalstead16 committed Oct 27, 2021
commit 0e86226818bef9064b658ff8963af529ea769fb4
44 changes: 27 additions & 17 deletions section2/exercises/comparisons.js
Original file line number Diff line number Diff line change
@@ -24,10 +24,10 @@ 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,
this statement still evaluated to true. JavaScript forces the stringTeachers into an integer to
@@ -36,7 +36,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,19 +49,19 @@ 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);

//-------------------
// PART 2: Articulating what you are doing
@@ -73,21 +73,30 @@ you develop good habits that follow best practice, from now on, use the strict c
// Make sure YOU can explain it that way!

console.log(4 < 9);
//YOU DO: Explain.
//YOU DO: The code in line 75 commands the console to log the result of the comparison number 4 is less than the number 9
// the return of the comparison will be true

var books = 3;
console.logs(4 < books);
// YOU DO: Explain.
console.log(4 < books);
// YOU DO: Line 78 commands the computer to store variable name books to have a value of the number 3
// Line 79 commands the console to log the comparison result of the number four is less than the books value which is the number three,
// the return of this comparison is false.

var friends = 6;
var siblings = 2;
console.log(friends > siblings);
// YOU DO: Explain.
// YOU DO: Line 83 commands the computer to store the variable name friends to have a value of the number 6
// Line 84 commands the computer to store the variable name siblings to have a value of the number 2
// Line 85 commands the console to log the results of the comparison variablies friends, a value of six, is greater than siblings, a value of 2.
// The return of the comparison is true

var attendees = 9;
var meals = 8;
console.log(attendees !== meals);
// YOU DO: Explain.
// YOU DO: Line 91 commands the computer to store the variable name attendees to have a value of the number 9
// Line 92 commands the computer to store the variable meals to have the value of the number 8
// Line 93 commands the console to log the results of the comparison of variables attendees, a value of 9, is not equal to meals, a value of 8
// The return of the comparison is true


//-------------------
@@ -110,18 +119,19 @@ 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);

// What did your final line of code evaluate to? Why do you think that is? Explain.
// ANSWER:
// ANSWER: Line 131 returned a value of 1, this happened because the value of number 1 is truthy, as is the value of lovesToPlay

//-------------------
// FINAL CHECK
14 changes: 13 additions & 1 deletion section2/exercises/decision-making.js
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ Spend some time changing the variables and running the file to see how the story

var doorChoice = 1;
var bearClothing = "";
var bearChoice = 1;
var bearChoice = 2;

console.log("You enter a dark room with two doors. Do you go through #1 or #2?");

@@ -38,16 +38,28 @@ if (bearChoice === 1) {
Questions

1. In English, using technical vocabulary, describe what is happening between lines 14 and 18.
Between lines 14 and 18 an if/else statement was created to set the conditions for the story execution. Depending on which value the variable has, the execution of the condition will change.

2. What variable has a new value assigned to it after the first if statement executes?
The bearClothing variable has a new value assigned after the doorChoice statement is executed.

3. If you changed the variable doorChoice to equal 3, what would the bearClothing value be?
If the variable doorChoice was equal to 3, the bearClothing value would be scarf.

4. In English, using technical vocabulary, describe what is happening between lines lines 27 and 35.
Between lines 27 and 25, the if/else statement is telling the console:
If the bearChoice variable is equal to 1, print the string line 28 including the if/else statement bearClothing result to the console.
If the bearChoice variable is equal to 2, returne line 30 with the previous if/else statements bearClothing result within the string to the console.
If the bearChoice variable is equal to 3, print the string in line 32 with to the console.
If the bearChoice variable is equal to anything other than 1, 2 or 3, print the string in line 35 to the console.

5. If you changed the variable bearChoice to equal 3, what will be the final outcome be?
The final outcome would be "You run as fast as you can into the next room. It's full of snakes!"

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 final ending would be "You tell the bear the hat is too small and it starts to cry!"

7. What is your favorite ending?
You stay with the bear and it becomes your best friend!

*/
34 changes: 30 additions & 4 deletions section2/exercises/functions.js
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ function printName() {
console.log("Severus Snape");
};

printName();
printName();
printName();
printName();
printName();
@@ -26,6 +26,13 @@ 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,18 +41,36 @@ 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(name)
};


greetMe("Casey");
greetMe("Zach");
greetMe("Zoey");
greetMe("Sammy");

// 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 math(num1, num2){
console.log(num1 + num2)
};

math(5, 3);
math(1, 2);
math(4,10);


// 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 flavorCombinations(flavor1, flavor2){
console.log("We go together like" + ' ' + flavor1 + ' ' + "and" + ' ' + flavor2 + ".")
};

flavorCombinations("peanut butter", "jelly");
flavorCombinations("peas", "carrots");
flavorCombinations("guace", "chips");


//-------------------
@@ -60,6 +85,7 @@ Look at the code you wrote for the previous YOU DO🎈 - what did you name the f
What did you name each parameter, and why?

EXPLAIN:
I named my function as flavorCombinations, because the sentence I was creating with concatenation was different flavor combinations.
Each parameter was give the title of flavor because each argument was going to be a flavor that paired well.


*/
*/
37 changes: 25 additions & 12 deletions section2/exercises/if-statements.js
Original file line number Diff line number Diff line change
@@ -31,19 +31,25 @@ 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;
var dogAge = 1;
// Write your conditional here

if (dogAge <= 2){
console.log('puppy');
} else if (dogAge >= 10){
console.log("elderly");
} else{
console.log('adult')
}

/*
YOU DO:
@@ -62,11 +68,14 @@ 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 === 3 || 2){
console.log("I have enough money for a gumball");
} else if (numQuarters === 0 || 1){
console.log("I don't have enough money for a gumball");
}


/*
@@ -82,15 +91,19 @@ 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 cupsOfFlour = 2;
var hasSauce = true;

// Write your conditional here

if (cupsOfFlour = 1, hasSauce === true || false){
console.log("I cannot make pizza");
} else if (cupsOfFlour === 2 || 3, hasSauce = true){
console.log("I can 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!

*/
*/
11 changes: 11 additions & 0 deletions section2/reflection.md
Original file line number Diff line number Diff line change
@@ -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?

In regards to asking questions, I feel I'm right in the middle. I mostly appreciated the last article "Your Questions are Ridiculous; Ask Them Anyway". The hardest part about Googling is that it doesn't understand where I am in my learning journey, what context I have, and what scope I'm looking for. I struggle with finding the "right" words to use for Googling, because I feel like by nature of still being in Mod 0, we only have a tiny amount of technical language to search with. On the flip side, I know that I've challenged myself and committed that I will continue to hone my Googling skills, and keep myself honest to my time and reach out when I need help. If I can describe what I have done to figure out the question, I haven't done enough research on my own.

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 was comfortable with running node to run my files, but at first I was frustrated by the amount of learning I had to do on my own, I always prefer a classroom setting, hence why I joined a bootcamp. But after getting through the comparisons section, wow that took a lot of extra googling, I'm honestly thankful for being pushed out of my comfort zone. One of my big goals to accomplish was to gain more confidence in my googling ability, and the push on independent learning in this section really strengthen my muscle. I think one of the biggest misses tradition education has is the lack of providing real world experience during the 4 year degree process. Teaching us how to teach ourselves (in a guided way by pointing us in the right direction in some areas) has really helped to build my confidence. Maybe I CAN do this!

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 provides code path options given certain conditions. An example of this in daily life is, if there are eggs in the refrigerator, make eggs for breakfast, if there are no eggs, eat nothing. An example of where a conditional is probably used in a web application is if there is an unread email in your inbox, put an alert of how many unread messages are next to the inbox title, if there are no unread messages, do nothing.

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.

Multiple conditions are added to a `if` statement by using `if/else` statements. Programs read if and if/else statements as having a series of options given different conditions. If the condition meets expectations of the if statement, meaning the if condition is true, it proceeds in that path. If the `if` condition is not true, meaning false, and an `if/else` condition has been set, the program will move to see if it can meet the `if/else` condition. If the `if/else` is true, the program will continue using the `if/else` condition path. The program will continuously check for a true condition until it arrives at the end of the code block.

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?

The tools available to a developer to check that TWO conditions are met would be to use the AND logical operator `&&` in the condition, to check if 1 of 2 conditions are met, the `||` OR logical operator would be used. Run the conditions through terminal using the node command to test if the conditions returned as expected.

1. What questions do you still have about `if` statements and/or functions?
I need to do more practice to see how `if` statement returns are manipulated by logical operators.