From 80dd187c26210322cad6f5731dbd26cd926242c3 Mon Sep 17 00:00:00 2001 From: Sukhada Gholba Date: Mon, 21 May 2018 12:02:50 -0700 Subject: [PATCH 1/5] initial commit-created objects --- assignments/objects.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/assignments/objects.js b/assignments/objects.js index 04399eda9..e7279a395 100644 --- a/assignments/objects.js +++ b/assignments/objects.js @@ -19,6 +19,42 @@ let example = { // Write your intern objects here: +let intern1 = { + "id": 1, + "name": "Mitzi", + "email": "mmelloy0@psu.edu", + "gender": "F" +}; + + +let intern2 = { + "id": 2, + "name": "Kennan", + "email": "kdiben1@tinypic.com", + "gender": "M" +}; + +let intern3 = { + "id": 3, + "name": "Keven", + "email": "kmummery2@wikimedia.org", + "gender": "M" +}; + +let intern4 = { + "id": 4, + "name": "Gannie", + "email": "gmartinson3@illinois.edu", + "gender": "M" +}; + +let intern5 = { + "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: From e49f7ce8bc1073c09f54c34bed6fa09db3e48e5a Mon Sep 17 00:00:00 2001 From: Sukhada Gholba Date: Mon, 21 May 2018 12:09:03 -0700 Subject: [PATCH 2/5] reading object data --- assignments/objects.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/assignments/objects.js b/assignments/objects.js index e7279a395..3bd0f1d65 100644 --- a/assignments/objects.js +++ b/assignments/objects.js @@ -60,14 +60,20 @@ let intern5 = { // Once your objects are created, log out the following requests from HR into the console: // Mitzi's name +intern1["name"]; // Kennan's ID +intern2["id"]; // Keven's email +intern3["email"]; // Gannie's name +intern4["name"]; // Antonietta's Gender +intern5["gender"]; + // ==== Challenge 3: Object Methods ==== // Give Kennan the ability to say "Hello, my name is Kennan!" Use the console.log provided as a hint. From cbd1e0225bafdb725fe12e1e15f728c4250979a1 Mon Sep 17 00:00:00 2001 From: Sukhada Gholba Date: Mon, 21 May 2018 12:18:13 -0700 Subject: [PATCH 3/5] created object methods --- assignments/objects.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/assignments/objects.js b/assignments/objects.js index 3bd0f1d65..8329cf887 100644 --- a/assignments/objects.js +++ b/assignments/objects.js @@ -79,9 +79,23 @@ intern5["gender"]; // Give Kennan the ability to say "Hello, my name is Kennan!" Use the console.log provided as a hint. // console.log(kennan.speak()); +intern2.speak = function(){ + return "Hello, my name is Kennan"; +} + + console.log(intern2.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)); +intern5.multiplyNums = function(a,b){ + return (a*b); +}; + +console.log(intern5.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 ==== From ac078499987392027b6d6a87b9615bf7d05945ed Mon Sep 17 00:00:00 2001 From: Sukhada Gholba Date: Mon, 21 May 2018 13:14:32 -0700 Subject: [PATCH 4/5] Objects Stretch Goal completed --- assignments/objects.js | 58 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/assignments/objects.js b/assignments/objects.js index 8329cf887..36436db36 100644 --- a/assignments/objects.js +++ b/assignments/objects.js @@ -81,7 +81,7 @@ intern5["gender"]; intern2.speak = function(){ return "Hello, my name is Kennan"; -} +}; console.log(intern2.speak()); @@ -105,16 +105,70 @@ console.log(intern5.multiplyNums(3,4)); // 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. -let parent = {} +let parent = { + "name": "Susan", + "age": 70, + + "child": { + "name": "George", + "age": 50, + "grandchild": { + "name": "Sam", + "age": 30 + } + + } +} + +parent.speak = function(){ + return ("Hello, my name is "+this.name); +}; + +parent.speak(); + + + +parent.child.speak = function(){ + return ("Hello, my name is "+this.name); +}; + + +parent.child.grandchild.speak = function(){ + return ("Hello, my name is "+this.name); +}; + +parent.child.grandchild.speak(); + + + // Log the parent object's name +parent.name; +//Susan // Log the child's age +parent.child.age; +//50 // Log the name and age of the grandchild +parent.child.grandchild.name; +//Sam + +parent.child.grandchild.age; +//30 // Have the parent speak +parent.speak(); + +//'Hello, my name is Susan' // Have the child speak +parent.child.speak(); + +//'Hello, my name is George' // Have the grandchild speak +parent.child.grandchild.speak(); + +// 'Hello, my name is Sam' + From 5d358741210490e79956a5bc70fd180ab19e18cd Mon Sep 17 00:00:00 2001 From: Sukhada Gholba Date: Mon, 21 May 2018 14:36:43 -0700 Subject: [PATCH 5/5] array assignment completed --- assignments/arrays.js | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/assignments/arrays.js b/assignments/arrays.js index c007f3e99..2dababe58 100644 --- a/assignments/arrays.js +++ b/assignments/arrays.js @@ -63,34 +63,65 @@ let inventory = [{"id":1,"car_make":"Lincoln","car_model":"Navigator","car_year" // ==== Challenge 1 ==== // The dealer can't recall the information for a car with an id of 33 on his lot. Help the dealer find out which car has an id of 33 by logging the car's year, make, and model in the console log provided to you below: -console.log(`Car 33 is a *car year goes here* *car make goes here* *car model goes here*` ); +console.log("Car 33 is a "+ inventory[32]["car_year"]+" "+ inventory[32]["car_make"]+" "+inventory[32]["car_model"]); // ==== Challenge 2 ==== // The dealer needs the information on the last car in their inventory. What is the make and model of the last car in the inventory? Log the make and model into the console. let lastCar = 0; -console.log(); +lastCar = inventory.length-1; +console.log("Make for the last car is "+inventory[lastCar]["car_make"]+" "+"and Model for the last car is "+inventory[lastCar]["car_model"]); + // ==== Challenge 3 ==== // The marketing team wants the car models listed alphabetically on the website. Sort all the car model names into alphabetical order and log the results in the console let carModels = []; -console.log(); + +for(let i=0; i