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

Patrick Findley #203

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
6 changes: 3 additions & 3 deletions day_1/exercises/booleans.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
In the exercises below, write your own code where indicated
to achieve the desired result.
to achieve the desired result.

A few are done for you already.

Expand All @@ -18,7 +18,7 @@ console.log(typeof (1 == 1));
console.log(1 == 2);

// example: log to the console the result of 7 is not equal to 2:
console.log(/*your code here*/);
console.log(7 != 2);

// example: log to the console the result of "hello" is equal to "Hello":

console.log("hello" == "Hello");
8 changes: 4 additions & 4 deletions day_1/exercises/concatenation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
In the exercises below, write your own code where indicated
to achieve the desired result.
to achieve the desired result.

A few are completed for you, to provide an example.

Expand All @@ -15,7 +15,7 @@ var team = "Chudley Cannons";
console.log("The " + team + " are " + name + "'s favorite Quidditch team");

// What happens if you include other data types when you use concatination? What data type is logged after we run this code?
// ANSWER to question on line 17:
// ANSWER to question on line 17: a string

var number = 7;
var creatures = "unicorns";
Expand All @@ -27,7 +27,7 @@ console.log("My zoo has " + number + " " + creatures + "!")
var speedy = "quick red fox";
var slowPoke = "lazy brown dog";

console.log(/*YOUR CODE HERE*/);
console.log("the " + speedy + " jumped over the " + slowPoke);

// Write code that combines the variables below into a string that
// reads "In a predictable result, the tortoise beat the hare!"
Expand All @@ -36,4 +36,4 @@ console.log(/*YOUR CODE HERE*/);
slowPoke = "tortoise";
speedy = "hare";

// YOUR CODE HERE
console.log("In a predictable result, the " + slowPoke + " beat the " + speedy + "!");
12 changes: 7 additions & 5 deletions day_1/exercises/numbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@ file from your terminal with the command `node day_1/exercises/numbers.js`
console.log(2 + 2);

// log the result of 7 subtracted from 83 console:
console.log(/*YOUR CODE HERE*/);
console.log(83 - 7);

// log the result of 6 multiplied by 53 to the console:
// YOUR CODE HERE
console.log(6 * 53);

// log the result of 20 divided by 4 to console:
// YOUR CODE HERE
console.log(20 / 4);

// log the result of the modulo of 10 into 54:
// YOUR CODE HERE
console.log(10 % 54);

// log the total number of snacks to the console, using the variables below:
var healthySnackCount = 7;
var junkFoodSnackCount = 4;
// YOUR CODE HERE
console.log(healthySnackCount + junkFoodSnackCount;
console.log("You've had " + healthySnackCount + " healthy snacks today.")
console.log("You've had " + junkFoodSnackCount + " junk food snacks today, tsk tsk.")
8 changes: 4 additions & 4 deletions day_1/exercises/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ file from your terminal with the command `node day_1/exercises/strings.js`
*/

// example: Write code below to log your name in the console:
console.log("Alan Turing");
console.log("Pat Findley");

// Write code below to log `Welcome to Turing!` in the console:
console.log(/*YOUR CODE HERE*/);
console.log("Welcome to Turing!");

// Write code below to log `99 bottles of pop on the wall...`:
// YOUR CODE HERE
console.log("99 bottles of pop on the wall...");

//Write code below to log one line from your favorite song or movie:
// YOUR CODE HERE
console.log("I figured out the message. One word, you know what it is? 'Stay'.")
11 changes: 6 additions & 5 deletions day_1/exercises/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@

// example: Write code below to assign your name to a variable and
// log that variable to the console:
var name = "Harry Potter";
var name = "Patrick Findley";
console.log(name);

// Write code below to assign the string 'Dobby' to a variable and
// log that variable to the console:
var houseElf = "Dobby";
// YOUR CODE HERE
console.log(houseElf)

// Write code below to save the string 'Harry Potter must not return to Hogwarts!'
// log that variable to the console:
// YOUR CODE HERE
var mortalDanger = "Harry Potter must not return to Hogwarts!";
console.log(mortalDanger)

// example: Write code below to add 2 to the variable `students` and
// log the result:
var students = 22;
// YOUR CODE HERE
students += 2;
console.log(students);

// Write the code below to subtract 2 students from the `students` variable and
// log the result:
// YOUR CODE HERE
students -= 2;
console.log(students);
13 changes: 12 additions & 1 deletion day_1/questions.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
## Day 1 Questions

1. How would you log the string `"Hello World!"` to the console?
* ``var string = "Hello World!";``
* ``console.log(string);``

1. What is the character you would use to indicate comments in a JavaScript file?
* ``//`` for one line of comments
* ``/* ... */`` for multiple lines of comments

1. Explain the difference between an integer and a floating-point number?

* An Integar is a whole number ``1``, ``2``, ``1941``
* A floating-point number is one which contains a decimal ``.75``, ``1.5``, ``2.25``
1. In the space below, create a variable `animal` that holds the string `"zebra"`.
* ```java Script

var animal = "zebra";
```
1. How would you log the string `"zebra"` using the variable that you created above?
* console.log(animal);

1. What is concatenation? Use concatenation to log a sentence to the console using the variable `animal`.
* Concatenation is a programming term which means ``join together``
* console.log("I don't know much about the " + animal + ", just that it's stripes act as a camouflage from predators.");
21 changes: 21 additions & 0 deletions day_2/array_methods.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Array Methods

## 1. Pop Method
* ``.pop()`` _removes the last element_ from an array, and returns that element to the caller
* Changes the length of the array
* ``arrayName.pop()`` removes last item from the ``arrayName`` ``array``

## 2. Push Method
* ``.push()`` _adds one more more elements_ to the end of an array and returns the new length of the array
* changes the length of the array
* ``arrayName.push("thing", 2, "thing 3")`` adds ``"thing"``, ``2``, and ``"thing 3"`` to the end of the ``arrayName`` `array``

## Shift Method
* ``.shift()`` _removes the first element_ from an array and returns that removed element to the caller
* _removes_ the elementh at the _zeroeth_ index, and shifts the values at consecutive indexes down
* ``arrayName.shift()`` removes first element from the ``arrayName`` ``array``

## Unshift Method
* ``.unshift()`` _add one or more elements_ to the beginning of an array, and returns the new length of the array
* _inserts_ given values to the beginning of an array-like object
* ``arrayName.unshift("thing", "thing 2", 3)`` adds ``"thing"``, ``"thing 2"``, and ``3`` to the beginning of the ``arrayName`` ``array``
24 changes: 14 additions & 10 deletions day_2/exercises/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,40 @@ var animals = ["Zebra", "Giraffe", "Elephant"];
console.log(animals);

// Declare a variable that will store an an array of at least 3 foods (strings)
// YOUR CODE HERE
var bestFoods = ["tacos", "nachos", "burritos", "pizza", "taco pizza"]

// example: Write code below that will log the number of elements in array of
// animals from above.
console.log(animals.length);

// Write code below that will log the number of elements in the array of
// foods from above.
// YOUR CODE HERE
console.log(bestFoods.length);

// Write code below that will log "Zebra" from the animals array
// YOUR CODE HERE
var firstAnimal = (animals[0]);
console.log(firstAnimal);

// Write code using bracket notation that will log the first item in the animals array
// YOUR CODE HERE
console.log(animals[0]); //

// Write code using bracket notation that will log the last item in the animals array
// YOUR CODE HERE
console.log(animals[2]); // should log "Elephant"

// Write code using bracket notation that will reassign the last item in the animals
// array to "Gorilla"
// YOUR CODE HERE
animals[2] = "Gorilla"
console.log(animals);

// Write code below that will log the last item from the foods array.
// YOUR CODE HERE
console.log(bestFoods[4]);

// Write code below that uses a method to add "lion" to the animals array and
// log the changed array to verify "lion" has been added
// YOUR CODE HERE
animals.push("Lion");
console.log(animals);

// Write code below that removes the last item of food from the foods array and
// log the cahnged array to verify that item has been removed
// YOUR CODE HERE
// log the changed array to verify that item has been removed
bestFoods.pop()
console.log(bestFoods)
20 changes: 10 additions & 10 deletions day_2/exercises/comparisons.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ var fourthVar = 0;
console.log(firstVar > secondVar); // this should return: false

// log the result of the comparison: is firstVar less than secondVar?
console.log(); // this should return: true
console.log(firstVar < secondVar); // this should return: true

// log the result of the comparison: is firstVar equal to thirdVar? (use the == operator)
console.log(); // this should return: true
console.log(firstVar == thirdVar); // this should return: true

/*
Note: this is an example of type coercion. Although thirdVar is a string and secondVar is an integer,
Expand All @@ -25,7 +25,7 @@ perform this evaluation
*/

// log the result of the comparison: is firstVar strictly equal to thirdVar? (use the === operator)
console.log(); // this should return: false
console.log(firstVar === thirdVar); // this should return: false

/*
Note: the strictly equal to operator compares the value of the variable in addition to the type of the variable.
Expand All @@ -34,26 +34,26 @@ the comparison still evaluates to false.
*/

// log the result of the comparison: is firstVar not equal to secondVar?
console.log(); // this should return: true
console.log(firstVar != secondVar); // this should return: true

// log the result of the comparison: is secondVar greater than or equal to 20?
console.log(); // this should return: true
console.log(secondVar >= 20); // this should return: true

// log the result of the comparison: is secondVar greater than or equal to 21?
console.log(); // this should return: false
console.log(secondVar >= 21); // this should return: false

// log the result of the comparison: is secondVar less than or equal to 20?
console.log(); // this should return: true
console.log(secondVar <= 20); // this should return: true

// log the result of the comparison: is secondVar less than or equal to 21?
console.log(); // this should return: true
console.log(secondVar <= 21); // this should return: true

// log the result of the comparison: is 0 equal to true?
console.log(0 == true) // this should return: false
console.log(0 == true); // this should return: false

// note: this is an example of a falsy value. In an evalution like this, 0 is considered to be false

// log the result of the comparison: is 1 equal to true?
console.log(1 == true) // this should return: true
console.log(1 == true); // this should return: true

// note: this is an example of a truthy value. In an evalution like this, 1 is considered to be true
13 changes: 10 additions & 3 deletions day_2/exercises/iteration.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,20 @@ for (var i = 0; i < animals.length; i++) {
// <animal> is awesome!" for each animal.

for (var i = 0; i < animals.length; i++) {
// YOUR CODE HERE
console.log("The " + animals[i] + " is awesome!")
}

// Create an array of foods and then iterate over that array to log "Add
// <food> to shopping list" for each food item.
// YOUR CODE HERE
var foodsToBuy = ["corn tortillas", "tomato", "onion", "avocado", "garlic", "cilantro", "pork shoulder"]
for (var i = 0; i < foodsToBuy.length; i++) {
console.log("Add " + foodsToBuy[i] + " to shopping list")
}

// Create an array of numbers and then iterate over that array to log doubles
// of each of the number.
// YOUR CODE HERE
var numbers = [3, 6, 9, 12]
for (var i = 0; i < numbers[i]; i++) {
console.log(numbers[i], numbers[i])

}
8 changes: 5 additions & 3 deletions day_2/exercises/loops.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@

// example: Write code that logs to the console your name 5 times:
for (var i = 0; i < 5; i++) {
console.log("Hermione Granger");
console.log("Patrick Findley");
}

// Write code below that logs to the console the sum of 2 plus 2 7 times:
for (var i = 0; i < 7; i++) {
// YOUR CODE HERE
console.log(2 + 2);
}

// Write code below that prints the phrase 'She sells seashells down by the seashore'
// 10 times.

// YOUR CODE HERE
for (var i = 0; i < 10; i++) {
console.log("She sells seashells down by the seashore")
}
8 changes: 8 additions & 0 deletions day_2/questions.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
## Day 2 Questions

1. Declare a variable named `animals` that stores an array containing the following strings: `"zebra", "giraffe", "elephant"`.
* var animals = ["zebra", "giraffe", "elephant"];

2. Using the array `animals`, how would you access `"giraffe"`?
* console.log(animals[1]);

3. How would you add `"lion"` to the `animals` array?
* animals.push("lion")

4. Name and describe two additional array methods.
* the ``pop method`` removes the last element in an array, and when logged returns that element back to the user. In our ``animals array`` it would be the ``"lion"`` we just _added_
* the ``shift method`` will do the same but to the element in the zeroeth index position. In the ``animals array`` that would remove and return ``"zebra"`` when logged.

5. What are the boolean values in JavaScript?
* ``true`` and ``false``

6. In JavaScript, how would you evaluate if `2` is equal to `25`? What is the result of this evaluation?
* ``console.log("2" == "25")`` would return ``false``

7. In JavaScript, how would you evaluate if `25` is greater than `2`? What is the result of this evaluation?
* ``console.log("25" >= "2")`` would return ``true``
Loading