From ba1e94d0a864f99e41536cc8c1873c489d361e54 Mon Sep 17 00:00:00 2001 From: Stella Date: Mon, 14 Oct 2019 15:31:17 -0700 Subject: [PATCH 1/3] finished with objects --- .DS_Store | Bin 0 -> 6148 bytes assignments/objects.js | 58 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..e06708acb60e1d76983bfd032fc47820f7638d47 GIT binary patch literal 6148 zcmeHK&2G~`5S~o~*s2gYAkpJqkT^sr28kRHlAET79x5S%-~gz#anxFJy;bZGl@R3D zfH&x)@B};#e6zb$DIwRWLNn3qH@lv1SNqx7A0kqNX%-Q6h$w(Fwn7yDFn-RyVlCg& z1}fXf36*q4W0dtuwlv&C1^C@Yy+m)54_4;LqbZ{LwFKh}N>wS#|DN zKhpCeuj*d!r)q7rZ{5BVgkccg4L*!c&1_UB^|Tr!lXte3XXDhzuZ=0L;v{{Ok7q}n z`+KIWle`>HmeSw9&CATp24-4jmF?$cQlElr2RiEP%;(XQr(GRI{Y6*L`~6;5KkG${ zMG!oA7`-?+KD+ol|FZb{%}$6EK4NS4JpO_22-b-7X*4MdQ=TA$*&)56ecGiV9ReTY z&yf8k<0Z0|Wkgj>6c7bOflVvmm%Ctl(*w(RqJSuH;}zibLBknikBvjSbfB`u)ei6f`|I!j*GW-k;-ho>~yXF8Gdu$w{1ttdpD}xlGz(y7L4Fw)>6#xJL literal 0 HcmV?d00001 diff --git a/assignments/objects.js b/assignments/objects.js index 798d5e0cf..719565f2a 100644 --- a/assignments/objects.js +++ b/assignments/objects.js @@ -19,26 +19,82 @@ const example = { // Write your intern objects here: +const interns = { + id: "idnum", + name: "intername", + gender: "MF", + email: "internemail", +} + + + +const person1 = { + id: 1, + name: "Mitzi", + gender: 'F', + email: "mmelloy0@psu.edu", +} +const person2 = { + id: 2, + name: "Kennan", + gender: 'M', + email: "kdiben1@tinypic.com", + more: function(speak) { + console.log(`${this.name} says ${speak}`); + } +} +const person3 = { + id: 3, + name: "Keven", + gender: 'M', + email: "kmummery2@wikimedia.org", +} +const person4 = { + id: 4, + name: "Gannie", + gender: 'M', + email: "gmartinson3@illinois.edu", +} +const person5 = { + id: 5, + name: "Antonietta", + gender: 'F', + email: "adaine5@samsung.com", + math: function(num1,num2){ + console.log(`${this.name} 7 * 7 is ${num1*num2}`); + } +} +person2.more("Hello, my name is Kennan!"); +person5.math(7, 7); + // ==== 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(person1.name); // Kennan's ID +console.log(person2.id); // Keven's email +console.log(person3.email); // Gannie's name +console.log(person4.name); // Antonietta's Gender +console.log(person5.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()); + + + // 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)); + // === 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 cc3975611da23602a3c8598187b7b70ff7db59f4 Mon Sep 17 00:00:00 2001 From: Stella Date: Tue, 15 Oct 2019 00:45:48 -0700 Subject: [PATCH 2/3] going to bed but still working on this --- assignments/arrays.js | 57 +++++++++++++++++++++++++++++++++++------- assignments/objects.js | 1 + 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/assignments/arrays.js b/assignments/arrays.js index 1dbf8bd35..0e2b14f31 100644 --- a/assignments/arrays.js +++ b/assignments/arrays.js @@ -75,30 +75,69 @@ 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*`); + + +const findCar = (carInventory, id) => { + for (i = 0; i < carInventory.length; i++) { + if (carInventory[i].id === id) { + return "Car " + id + " is a " + carInventory[i].car_year + " " + carInventory[i].car_make + " " + carInventory[i].car_model; + } + } +} +console.log(findCar(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(); + +const lastCar = [0]; +const last= inventory[inventory.length - 1]; +console.log(last); + + // ==== 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(); + + + +let carModels = ["Geo", 'Oldsmobile', 'Mazda', 'Chevrolet', 'Jeep','Eagle','Toyota', 'BMW', 'Cadillac', 'Infiniti', 'Suzuki', 'Mercury', 'Pontiac', 'Dodge', +'Ford', 'Chrysler', 'Volvo', 'Lotus', 'GMC', 'Mercedes-Benz', 'Audi', 'Volkswagen', 'Lincoln' ]; + +function alphabeticalOrder (carModels){ + + let carModelsSorted = carModels.sort( + ); +console.log(carModelsSorted); + return carModelsSorted; +} +alphabeticalOrder(['Geo', 'Oldsmobile', 'Mazda', 'Chevrolet', 'Jeep','Eagle','Toyota', 'BMW', 'Cadillac', 'Infiniti', 'Suzuki', 'Mercury', 'Pontiac', 'Dodge', +'Ford', 'Chrysler', 'Volvo', 'Lotus', 'GMC', 'Mercedes-Benz', 'Audi', 'Volkswagen', 'Lincoln']) + + // ==== 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(); + + +inventory.push('car_year'); + let carYears = ['1997', '1992','1998', '2012', '1996', '2009', '2008', '1995','2007', '1999', '2001', '2010', '1983', '1990', '1995', '1987', '2004', '1997','2000', '1994', '1985', '2003','2005', '1964', '2011', '1991', '1965', ]; +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. +carYears.sort(function(a,b){ + return a - b; +}); +console.log(carYears); let oldCars = []; -console.log(); +// console.log(); // ==== 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(); + +//if cartype =bmw else audi put into one array \ No newline at end of file diff --git a/assignments/objects.js b/assignments/objects.js index 719565f2a..da89b9462 100644 --- a/assignments/objects.js +++ b/assignments/objects.js @@ -95,6 +95,7 @@ console.log(person5.gender); // Antonietta loves math, give her the ability to multiply two numbers together and return the product. Use the console.log provided as a hint. +//****See above // === 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 c783c9b675d57566a43add2388b03060e98f6fb4 Mon Sep 17 00:00:00 2001 From: Stella Date: Tue, 15 Oct 2019 13:09:37 -0700 Subject: [PATCH 3/3] another push before 1x1 - slowly things are beginning to make sense but not enough --- assignments/arrays.js | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/assignments/arrays.js b/assignments/arrays.js index 0e2b14f31..9a2348b78 100644 --- a/assignments/arrays.js +++ b/assignments/arrays.js @@ -131,13 +131,38 @@ console.log(carYears); carYears.sort(function(a,b){ return a - b; }); -console.log(carYears); -let oldCars = []; -// console.log(); +console.log(carYears) + +// let oldCarYears = ["1964", "1965", "1983", "1985", "1987", "1990", "1991", "1992", "1994", "1995", "1995", "1996", "1997", "1997", "1998", "1999", "2000", "2001", "2003", "2004", "2005", "2007", "2008", "2009", "2010", "2011", "2012"]; +const oldCars = +inventory.filter(function(currentValue){ + return currentValue.car_year < 2000 ; +}) +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(); +const audiFilter = +inventory.filter(function(currentValue){ +return currentValue.car_make === "Audi"; +}) +const BMWFilter = +inventory.filter(function(currentValue){ + return currentValue.car_make === "BMW" +}) +// function getValues(firstValue, secondValue) { +// return [getFirstValue(), getSecondValue()]; +// } +// const{first, second} = getValues(); + +// // BMWAndAudi.forEach(function(items){ +// // return BMWAndAudi.push(`${items.car_make} ${items.car_model}`); + +// }); +console.log(BMWFilter); +console.log(audiFilter); +console.log(BMWAndAudi); + //if cartype =bmw else audi put into one array \ No newline at end of file