Repository navigation
WEBEU1 Connor robertson #1
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7a426b9
init commit
ConConRob ffcde4f
done object challenges
ConConRob 9197f64
done all the array challenges
ConConRob 12f2125
done object stretch
ConConRob 67898e7
DONE EVERYTHING
ConConRob 56c9c58
put in a failsafe in the short that caps the first letter of every mo…
ConConRob File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,28 +18,60 @@ const example = { | |
| } | ||
|
|
||
| // Write your intern objects here: | ||
|
|
||
|
|
||
| const mitzi = { | ||
| "id": 1, | ||
| "name": "Mitzi", | ||
| "email": "mmelloy0@psu.edu", | ||
| "gender": "F", | ||
| } | ||
| const kennan = { | ||
| "id": 2, | ||
| "name": "Kennan", | ||
| "email": "kdiben1@tinypic.com", | ||
| "gender": "M", | ||
| } | ||
| const keven = { | ||
| "id": 3, | ||
| "name": "Mitzi", | ||
| "email": "kmummery2@wikimedia.org", | ||
| "gender": "M", | ||
| } | ||
| const gannie = { | ||
| "id": 4, | ||
| "name": "Gannie", | ||
| "email": "gmartinson3@illinois.edu", | ||
| "gender": "M", | ||
| } | ||
| const antonietta = { | ||
| "id": 5, | ||
| "name": "Antonietta", | ||
| "email": "adaine5@samsung.com", | ||
| "gender": "F", | ||
| } | ||
| // ==== Challenge 2: Reading Object Data ==== | ||
| // Once your objects are created, log out the following requests from HR into the console: | ||
|
|
||
| // Mitzi's name | ||
|
|
||
| console.log(mitzi.name); | ||
| // Kennan's ID | ||
|
|
||
| console.log(kennan.id); | ||
| // Keven's email | ||
|
|
||
| console.log(keven.email); | ||
| // Gannie's name | ||
|
|
||
| console.log(gannie.name); | ||
| // Antonietta's Gender | ||
|
|
||
| console.log(antonietta.gender); | ||
| // ==== Challenge 3: Object Methods ==== | ||
| // Give Kennan the ability to say "Hello, my name is Kennan!" Use the console.log provided as a hint. | ||
| // console.log(kennan.speak()); | ||
|
|
||
| kennan.speak = function(){ | ||
| return `Hello, my name is ${this.name}`; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good job using template literals. |
||
| } | ||
| //console.log(kennan.speak()); | ||
| // Antonietta loves math, give her the ability to multiply two numbers together and return the product. Use the console.log provided as a hint. | ||
| //console.log(antonietta.multiplyNums(3,4)); | ||
|
|
||
| antonietta.multiplyNums = (x, y) => x*y; | ||
| //console.log(antonietta.multiplyNums(3,4)) | ||
| // === Great work! === Head over to the the arrays.js file or take a look at the stretch challenge | ||
|
|
||
| // ==== Stretch Challenge: Nested Objects and the this keyword ==== | ||
|
|
@@ -49,16 +81,31 @@ const example = { | |
| // 3. Nest a grandchild object in the child object with properties for name and age. The name will be Sam and the age will be 30 | ||
| // 4. Give each of the objects the ability to speak their names using the this keyword. | ||
|
|
||
| const parent = {} | ||
| const parent = { | ||
| name: "Susan", | ||
| age: 70, | ||
| speak: function () {console.log(`My name is ${this.name}`);}, | ||
| child: { | ||
| name: "George", | ||
| age: 50, | ||
| speak: function () {console.log(`My name is ${this.name}`);}, | ||
| grandchild: { | ||
| name: "Sam", | ||
| age: 30, | ||
| speak: function () {console.log(`My name is ${this.name}`);}, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Log the parent object's name | ||
|
|
||
| console.log(parent.name); | ||
| // Log the child's age | ||
|
|
||
| console.log(parent.child.name); | ||
| // Log the name and age of the grandchild | ||
|
|
||
| console.log(parent.child.grandchild.name); | ||
| // Have the parent speak | ||
|
|
||
| parent.speak(); | ||
| // Have the child speak | ||
|
|
||
| parent.child.speak(); | ||
| // Have the grandchild speak | ||
| parent.child.grandchild.speak(); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,28 @@ | ||
| // Take the commented ES5 syntax and convert it to ES6 arrow Syntax | ||
|
|
||
| // let myFunction = function () {}; | ||
|
|
||
| const myFunction = () => {}; | ||
| // let anotherFunction = function (param) { | ||
| // return param; | ||
| // }; | ||
|
|
||
| const anotherFunction = param => param; | ||
| // let add = function (param1, param2) { | ||
| // return param1 + param2; | ||
| // }; | ||
| // add(1,2); | ||
|
|
||
| const add = (param1, param2) => param1+param2; | ||
| console.log(add(1,2)); | ||
| // let subtract = function (param1, param2) { | ||
| // return param1 - param2; | ||
| // }; | ||
| // subtract(1,2); | ||
|
|
||
| const subtract = (param1, param2) => param1 - param2; | ||
| console.log(subtract(1,2)); | ||
| // exampleArray = [1,2,3,4]; | ||
| // const triple = exampleArray.map(function (num) { | ||
| // return num * 3; | ||
| // }); | ||
| // console.log(triple); | ||
| // console.log(triple); | ||
| exampleArray = [1,2,3,4]; | ||
| const triple = exampleArray.map(num => num*3); | ||
| console.log(triple); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nicely done with your writing your objects.