From e303b0fb9d70175f667c5beb4bacfe44cf714d23 Mon Sep 17 00:00:00 2001 From: wktg623 Date: Sun, 29 Sep 2019 12:03:52 -0500 Subject: [PATCH 1/5] sample change to test node --- assignments/arrays.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assignments/arrays.js b/assignments/arrays.js index 1dbf8bd35..4f0f3f466 100644 --- a/assignments/arrays.js +++ b/assignments/arrays.js @@ -76,7 +76,7 @@ let inventory = [ // ==== 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("afd"); // ==== 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; From d612ec231cad87e9cc6f834a51e83984fa4d6a48 Mon Sep 17 00:00:00 2001 From: wktg623 Date: Mon, 30 Sep 2019 21:27:41 -0500 Subject: [PATCH 2/5] done with the majority of challenges --- assignments/arrays.js | 26 ++++++++++++----- assignments/function-conversion.js | 15 +++++++++- assignments/objects.js | 46 ++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 8 deletions(-) diff --git a/assignments/arrays.js b/assignments/arrays.js index 4f0f3f466..81cccb0da 100644 --- a/assignments/arrays.js +++ b/assignments/arrays.js @@ -75,23 +75,36 @@ let inventory = [ // ==== 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("afd"); + +console.log("Car 33 is a " + (Object.values(inventory[32]))[3] + " " + (Object.values(inventory[32]))[1] + " " + (Object.values(inventory[32]))[2] + "." ) +console.log(inventory[33]); + // ==== 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(); +let lastCar = []; +for(i = 0; i {return param}; +anotherFunction("Example"); + + // let add = function (param1, param2) { // return param1 + param2; // }; // add(1,2); +let add = (param1, param2) => {return param1 + param2;} +console.log(add(1,2)); // let subtract = function (param1, param2) { // return param1 - param2; // }; // subtract(1,2); +let subtract = (param1, param2) => {return param1 - param2}; +console.log(subtract(1,2)); // Stretch @@ -27,4 +37,7 @@ // const triple = exampleArray.map(function (num) { // return num * 3; // }); -// console.log(triple); \ No newline at end of file +// console.log(triple); +exampleArray = [1,2,3,4]; +const triple = exampleArray.map(num => num *3); +console.log(triple); diff --git a/assignments/objects.js b/assignments/objects.js index 798d5e0cf..9a299441f 100644 --- a/assignments/objects.js +++ b/assignments/objects.js @@ -18,6 +18,41 @@ const example = { } // Write your intern objects here: +const intern1 = { + id: 1, + email: "mmelloy0@PushSubscription.edu", + firstName: "Mitzi", + gender: "F" +}; + +const intern2 = { + id: 2, + email: "kdiben1@tinypic.com", + firstName: "Kennan", + gender: 'M' +}; + +const intern3 = { + id: 3, + email: "kmummery2@wikimedia.org", + firstName: "Keven", + gender: 'M' +}; + +const intern4 = { + id: 4, + email: "gmartinson3@illinois.edu", + firstName: "Gannie", + gender: 'M' +}; + +const intern5 = { + id: 1, + email: "adaine5@samsung.com", + firstName: "Antonietta", + gender: 'F' +} + // ==== Challenge 2: Reading Object Data ==== @@ -33,12 +68,23 @@ const example = { // Antonietta's Gender +console.log(intern1.firstName); //returns Mitzi +console.log(intern2.id); //returns 2 +console.log(intern3.email); //returns kmummery2@wikimedia.org +console.log(intern4.firstName); //returns Gannie +console.log(intern5.gender); //returns F + // ==== 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()); +console.log("Hello, my name is " + intern2.firstName + "!") + // 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)); +let multiplyNums = (a,b) => {return a*b}; + +console.log(intern5.firstName + " can multiply two numbers together as evidenced that she knows 3 multiplied by 7 = " + multiplyNums(3,7)) // === Great work! === Head over to the the arrays.js. You may come back and attempt the Stretch Challenge once you have completed the challenges in arrays.js and function-conversion.js. From f700bdbcd374946b35ee2b9f70a88b78e9c8856a Mon Sep 17 00:00:00 2001 From: wktg623 Date: Tue, 1 Oct 2019 20:43:48 -0500 Subject: [PATCH 3/5] done --- assignments/arrays.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/assignments/arrays.js b/assignments/arrays.js index 81cccb0da..303e8812f 100644 --- a/assignments/arrays.js +++ b/assignments/arrays.js @@ -108,9 +108,16 @@ console.log(carYears); // ==== Challenge 5 ==== // The car lot manager needs to find out how many cars are older than the year 2000. Using the carYears array you just created, find out how many cars were made before the year 2000 by populating the array oldCars and logging it's length. -let oldCars = []; -console.log(); +let oldCars = []; +for(i = 0; i Date: Tue, 1 Oct 2019 21:22:53 -0500 Subject: [PATCH 4/5] done with stretch --- assignments/objects.js | 45 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/assignments/objects.js b/assignments/objects.js index 9a299441f..f123e780c 100644 --- a/assignments/objects.js +++ b/assignments/objects.js @@ -95,16 +95,51 @@ console.log(intern5.firstName + " can multiply two numbers together as evidenced // 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", -// Log the parent object's name + age: 70, -// Log the child's age +child: + {name: "George", + +age: 50, + +grandchild: + {name: "Sam", + +age: 30, + +speaks: function(){ + return this.name + " speaks!"} + +} + +, +speaks: function(){ + return this.name + " speaks!"} + +} + +, +speaks: function(){ + return this.name + " speaks!"} + + +} + + +// Log the parent object's name +console.log(parent.name); +// Log the child's age +console.log(parent.child.age); // Log the name and age of the grandchild +console.log(parent.child.grandchild) // Have the parent speak - +console.log(parent.speaks()); // Have the child speak - +console.log(parent.child.speaks()); // Have the grandchild speak +console.log(parent.child.grandchild.speaks()); \ No newline at end of file From 547e8307122ee8d017182407fad00dd6a91477ac Mon Sep 17 00:00:00 2001 From: wktg623 Date: Wed, 2 Oct 2019 23:04:38 -0500 Subject: [PATCH 5/5] fixed the speaks() --- assignments/arrays.js | 2 +- assignments/objects.js | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/assignments/arrays.js b/assignments/arrays.js index 303e8812f..0bc2b1c5a 100644 --- a/assignments/arrays.js +++ b/assignments/arrays.js @@ -76,7 +76,7 @@ let inventory = [ // ==== 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 " + (Object.values(inventory[32]))[3] + " " + (Object.values(inventory[32]))[1] + " " + (Object.values(inventory[32]))[2] + "." ) +//console.log("Car 33 is a " + (Object.values(inventory[32]))[3] + " " + (Object.values(inventory[32]))[1] + " " + (Object.values(inventory[32]))[2] + "." ) console.log(inventory[33]); // ==== Challenge 2 ==== diff --git a/assignments/objects.js b/assignments/objects.js index f123e780c..2d82cb6b2 100644 --- a/assignments/objects.js +++ b/assignments/objects.js @@ -29,7 +29,10 @@ const intern2 = { id: 2, email: "kdiben1@tinypic.com", firstName: "Kennan", - gender: 'M' + gender: 'M', + speak(){ + return `Hello my name is ${this.firstName}!`; + } }; const intern3 = { @@ -78,8 +81,8 @@ console.log(intern5.gender); //returns F // Give Kennan the ability to say "Hello, my name is Kennan!" Use the console.log provided as a hint. // console.log(kennan.speak()); -console.log("Hello, my name is " + intern2.firstName + "!") - +console.log("Hello, my name is " + intern2.firstName + "!"); +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)); let multiplyNums = (a,b) => {return a*b};