From 91581599cd5a0593b175543fb153bcb7097d8aff Mon Sep 17 00:00:00 2001 From: Sarah Elias Date: Mon, 14 Oct 2019 12:41:57 -0700 Subject: [PATCH 1/4] created objects --- assignments/objects.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/assignments/objects.js b/assignments/objects.js index 798d5e0cf..2d936faa1 100644 --- a/assignments/objects.js +++ b/assignments/objects.js @@ -19,6 +19,40 @@ const example = { // Write your intern objects here: +const mitzi = { + id: 1, + email: 'mmelloy@psu.edu', + firstName: 'Mitzi', + gender: 'F', +} + +const kennan = { + id: 2, + email: 'kdiben1@tinypic.com', + firstName: 'Kennan', + gender: 'M' +} + +const keven = { + id: 3, + email: 'kmummery2@wikimedia.org', + firstName: 'Keven', + gender: 'M' +} + +const gannie = { + id: 4, + email: 'gmartinson3@illinois.edu', + firstName: 'Gannie', + gender: 'F' +} + +const antonietta = { + id: 5, + email: 'adaine5@samsung.com', + firstName: 'Antonietta', + gender: 'F' +} // ==== Challenge 2: Reading Object Data ==== // Once your objects are created, log out the following requests from HR into the console: From 85a89f66ec7d41e7dd879f53d64d2c3022136f53 Mon Sep 17 00:00:00 2001 From: Sarah Elias Date: Mon, 14 Oct 2019 14:05:22 -0700 Subject: [PATCH 2/4] finished objects --- .DS_Store | Bin 0 -> 6148 bytes assignments/objects.js | 32 +++++++++++++++++++++++--------- 2 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d1f069b055e82da15e37490cda539f06bb255b5b GIT binary patch literal 6148 zcmeHKIc~#13?vg30^GPvxnJ-P7J~DFd?3DH7*OIuNw3Q9%F{AD8bNkvH^xvPXP4rv zpeaOAM6~A!;D$AE4D?S2f{y^e25C2} zeU<Eo^g9;3)=7^y|N4{iTO&kM*E}FxK=94ui6!oX${Nm-JHIR`CP=Toe zud!WP|9^+ynE$6F?x+A2cq#?7S%0iMyi)eo*~?k4E$~mc)%?NDuyzW9w_~8UV{EJ) ezj;yA6{24G^XjI_Q3j71`>=q#a literal 0 HcmV?d00001 diff --git a/assignments/objects.js b/assignments/objects.js index 2d936faa1..c46436cf6 100644 --- a/assignments/objects.js +++ b/assignments/objects.js @@ -15,7 +15,7 @@ const example = { name: "Example", email: "examples@you.edu", gender: "F", -} +}; // Write your intern objects here: @@ -24,55 +24,69 @@ const mitzi = { email: 'mmelloy@psu.edu', firstName: 'Mitzi', gender: 'F', -} +}; const kennan = { id: 2, email: 'kdiben1@tinypic.com', firstName: 'Kennan', - gender: 'M' -} + gender: 'M', + speak: function(name){ + return "Hello, my name is Kennan!" + } +}; const keven = { id: 3, email: 'kmummery2@wikimedia.org', firstName: 'Keven', - gender: 'M' -} + gender: 'M', +}; const gannie = { id: 4, email: 'gmartinson3@illinois.edu', firstName: 'Gannie', gender: 'F' -} +}; const antonietta = { id: 5, email: 'adaine5@samsung.com', firstName: 'Antonietta', - gender: 'F' -} + gender: 'F', + multiplyNums: function(num1,num2){ + return num1 * num2 + } +}; // ==== 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.firstName); // Kennan's ID +console.log(kennan.id); // Keven's email +console.log(keven.email); // Gannie's name +console.log(gannie.firstName); // 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()); +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)); +console.log(antonietta.multiplyNums(5,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 4dd2c38dc6092d95eeead0f1f5f3772da6d54c19 Mon Sep 17 00:00:00 2001 From: Sarah Elias Date: Mon, 14 Oct 2019 18:07:54 -0700 Subject: [PATCH 3/4] function conversion done --- assignments/arrays.js | 17 +++++++++++++---- assignments/function-conversion.js | 18 +++++++++++++++++- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/assignments/arrays.js b/assignments/arrays.js index 1dbf8bd35..524f86e09 100644 --- a/assignments/arrays.js +++ b/assignments/arrays.js @@ -80,18 +80,27 @@ console.log(`Car 33 is a *car year goes here* *car make goes here* *car model go // ==== 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= invventory[inventory.length -1] + + +console.log('${lastcar.car_make} ${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 = []; -let carModelsSorted = []; -console.log(); +for (let i =0; i < inventory.length; i++){ + carModels.push(inventory[i].car_model) +} +carModels.sort(); +console.log(carModels); // ==== Challenge 4 ==== // The accounting team needs all the years from every car on the lot. Create a new array from the dealer data containing only the car years and log the result in the console. let carYears = []; -console.log(); +for (let i = 0; i < inventory.length; i++){ + carYears.push(inventory[i].car_year) +} +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. diff --git a/assignments/function-conversion.js b/assignments/function-conversion.js index 55f57ef62..da194dd1e 100644 --- a/assignments/function-conversion.js +++ b/assignments/function-conversion.js @@ -5,21 +5,36 @@ // }; // myFunction(); +const myFunction = () => { +return ('Function was invoked!'); +}; +console.log(myFunction()); + // let anotherFunction = function (param) { // return param; // }; // anotherFunction("Example"); +const anotherFunction = (param) => { + return param; +}; +console.log(anotherFunction("example")); + // 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)); // Stretch @@ -27,4 +42,5 @@ // const triple = exampleArray.map(function (num) { // return num * 3; // }); -// console.log(triple); \ No newline at end of file +// console.log(triple); + From 3b2d99557af1e4b6ac5fd859de25b111bb8f8a0b Mon Sep 17 00:00:00 2001 From: Sarah Elias Date: Thu, 17 Oct 2019 20:02:29 -0700 Subject: [PATCH 4/4] finished array --- assignments/arrays.js | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/assignments/arrays.js b/assignments/arrays.js index 524f86e09..daff3723f 100644 --- a/assignments/arrays.js +++ b/assignments/arrays.js @@ -75,18 +75,26 @@ 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*`); + + +for (let i = 0; i < inventory.length; i++){ + if (inventory[i].id === 33){ + console.log(`Car 33 is a ${inventory[i].car_year} ${inventory[i].car_make} ${inventory[i].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; -lastCar= invventory[inventory.length -1] - -console.log('${lastcar.car_make} ${lastCar.car_model}'); +let lastCar = inventory[inventory.length -1] +console.log(`The last car is a ${lastCar.car_make} ${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 +// // ==== 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 = []; for (let i =0; i < inventory.length; i++){ carModels.push(inventory[i].car_model) @@ -94,20 +102,27 @@ for (let i =0; i < inventory.length; i++){ carModels.sort(); console.log(carModels); -// ==== Challenge 4 ==== +// // ==== Challenge 4 ==== // The accounting team needs all the years from every car on the lot. Create a new array from the dealer data containing only the car years and log the result in the console. let carYears = []; for (let i = 0; i < inventory.length; i++){ - carYears.push(inventory[i].car_year) + carYears.push (inventory[i]['car_year']) } 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(); +for (let i = 0; i < carYears.length; i++) { + if (carYears[i] < 2000) { + oldCars.push (carYears[i]) + } +} + +console.log(oldCars.length); // ==== Challenge 6 ==== // A buyer is interested in seeing only BMW and Audi cars within the inventory. Return an array that only contains BMW and Audi cars. Once you have populated the BMWAndAudi array, use JSON.stringify() to show the results of the array in the console. -let BMWAndAudi = []; -console.log(); +// let BMWAndAudi = []; + +// console.log();