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

Robby DeRouin Mod 1 Prework #204

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
15 changes: 12 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,16 @@ 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")

/*robertsmacbookpro@Roberts-MacBook-Pro exercises % node booleans.js
boolean
boolean
false
true
false
robertsmacbookpro@Roberts-MacBook-Pro exercises %
*/
19 changes: 12 additions & 7 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 @@ -14,8 +14,8 @@ 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:
// What happens if you include other data types when you use concatination? What data type is logged after we run this code? My zoo has 7 unicorns!
// ANSWER to question on line 17:

var number = 7;
var creatures = "unicorns";
Expand All @@ -27,13 +27,18 @@ 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!"
// Note that we are omitting the var keyword below, because we are re-assigning the variables

slowPoke = "tortoise";
speedy = "hare";
var sloweyPokey = "tortoise";
var speedster = "hare";

// YOUR CODE HERE
console.log("In a predictable result, the " + sloweyPokey + " beat the " + speedster +"!")

/* The Chudley Cannons are Ron's favorite Quidditch team
My zoo has 7 unicorns!
The quick red fox jumped over the lazy brown dog.
In a predictable result, the tortoise beat the hare!*/
27 changes: 22 additions & 5 deletions day_1/exercises/numbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,35 @@ 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)

/*robertsmacbookpro@Roberts-MacBook-Pro day_1 % pwd
/Users/robertsmacbookpro/turing/0module/frontend-mod-1-prework/day_1
robertsmacbookpro@Roberts-MacBook-Pro day_1 % ls
README.md exercises questions.md
robertsmacbookpro@Roberts-MacBook-Pro day_1 % cd exercises
robertsmacbookpro@Roberts-MacBook-Pro exercises % ls
booleans.js numbers.js variables.js
concatenation.js strings.js
robertsmacbookpro@Roberts-MacBook-Pro exercises % node numbers.js
4
76
318
5
10
11
*/
16 changes: 13 additions & 3 deletions day_1/exercises/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,20 @@ file from your terminal with the command `node day_1/exercises/strings.js`
console.log("Alan Turing");

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

// 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("Open the pod bay doors HAL!")

/*robertsmacbookpro@Roberts-MacBook-Pro exercises % ls
booleans.js numbers.js variables.js
concatenation.js strings.js
robertsmacbookpro@Roberts-MacBook-Pro exercises % node strings.js
Alan Turing
Robert DeRouin
99 bottles of pop on the wall...
Open the pod bay doors HAL!
robertsmacbookpro@Roberts-MacBook-Pro exercises % */
20 changes: 12 additions & 8 deletions day_1/exercises/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,23 @@ 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 dobbyThreat = "Harry Potter must not return to Hogwarts!";
console.log(dobbyThreat);

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

// Write the code below to subtract 2 students from the `students` variable and
// log the result:
// YOUR CODE HERE
console.log(students);
console.log(students - 2);

/*Harry Potter
Dobby
Harry Potter must not return to Hogwarts!
24
20
*/
17 changes: 17 additions & 0 deletions day_1/questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,29 @@

1. How would you log the string `"Hello World!"` to the console?

console.log("Hello World!");

1. What is the character you would use to indicate comments in a JavaScript file?

//For single line comments//
/*For multi line comments*/

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

Integers are whole numbers, negative or positive or 0.

Floating-point Numbers have decimal places.

1. In the space below, create a variable `animal` that holds the string `"zebra"`.

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 the operation of joining character strings end-to-end.

console.log(animal + " have black and white stripes!");
107 changes: 107 additions & 0 deletions day_2/array_methods.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
Constructor
Array
Creates a new Array object.

Static Properties
get Array[]
The constructor function is used to create derived objects.

Array.from()
Creates a new Array instance from an array-like or iterable object.

Array.isArray()
Returns true if the argument is an array, or false otherwise.

Array.of()
Creates a new Array instance with a variable number of arguments, regardless of number or type of the arguments.

Array.prototype.concat()
Returns a new array that is this array joined with other array(s) and/or value(s).

Array.prototype.copyWithin()
Copies a sequence of array elements within the array.

Array.prototype.entries()
Returns a new Array Iterator object that contains the key/value pairs for each index in the array.

Array.prototype.every()
Returns true if every element in this array satisfies the testing function.

Array.prototype.fill()
Fills all the elements of an array from a start index to an end index with a static value.

Array.prototype.filter()
Returns a new array containing all elements of the calling array for which the provided filtering function returns true.

Array.prototype.find()
Returns the found element in the array, if some element in the array satisfies the testing function, or undefined if not found.

Array.prototype.findIndex()
Returns the found index in the array, if an element in the array satisfies the testing function, or -1 if not found.

Array.prototype.forEach()
Calls a function for each element in the array.

Array.prototype.includes()
Determines whether the array contains a value, returning true or false as appropriate.

Array.prototype.indexOf()
Returns the first (least) index of an element within the array equal to an element, or -1 if none is found.

Array.prototype.join()
Joins all elements of an array into a string.

Array.prototype.keys()
Returns a new Array Iterator that contains the keys for each index in the array.

Array.prototype.lastIndexOf()
Returns the last (greatest) index of an element within the array equal to an element, or -1 if none is found.

Array.prototype.map()
Returns a new array containing the results of calling a function on every element in this array.

Array.prototype.pop()
Removes the last element from an array and returns that element.

Array.prototype.push()
Adds one or more elements to the end of an array, and returns the new length of the
array.

Array.prototype.reduce()
Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value.

Array.prototype.reduceRight()
Apply a function against an accumulator> and each value of the array (from right-to-left) as to reduce it to a single value.

Array.prototype.reverse()
Reverses the order of the elements of an array in place. (First becomes the last, last becomes first.)

Array.prototype.shift()
Removes the first element from an array and returns that element.

Array.prototype.slice()
Extracts a section of the calling array and returns a new array.

Array.prototype.some()
Returns true if at least one element in this array satisfies the provided testing function.

Array.prototype.sort()
Sorts the elements of an array in place and returns the array.

Array.prototype.splice()
Adds and/or removes elements from an array.

Array.prototype.toLocaleString()
Returns a localized string representing the array and its elements. Overrides the Object.prototype.toLocaleString() method.

Array.prototype.toString()
Returns a string representing the array and its elements. Overrides the Object.prototype.toString() method.

Array.prototype.unshift()
Adds one or more elements to the front of an array, and returns the new length of the array.

Array.prototype.values()
Returns a new Array Iterator object that contains the values for each index in the array.

Array.prototype[@@iterator]()
Returns a new Array Iterator object that contains the values for each index in the array.
24 changes: 15 additions & 9 deletions day_2/exercises/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,42 @@ 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 foods = ["Corn", "Apple", "Tomato"];
console.log(foods);

// 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(foods.length);

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

// 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]);

// 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(foods[2]);

// 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
foods.pop();
console.log(foods);
Loading