From adb1222dbaeac48967fc89b0fda50d8cba7cc59e Mon Sep 17 00:00:00 2001 From: Arthur Pisakhov Date: Mon, 21 May 2018 16:18:06 -0400 Subject: [PATCH 1/3] Initial commit --- assignments/objects.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/assignments/objects.js b/assignments/objects.js index 04399eda9..0613b2b55 100644 --- a/assignments/objects.js +++ b/assignments/objects.js @@ -19,11 +19,42 @@ let example = { // Write your intern objects here: +let intOne = { + "id": 1, + "name": "Mitzi", + "email": "Mitzi@you.edu", + "gender": "F" +} +let intTwo = { + "id": 2, + "name": "Kennan", + "email": "Kennan@you.edu", + "gender": "M" +} +let intThree = { + "id": 3, + "name": "Keven", + "email": "Keven@you.edu", + "gender": "M" +} +let intFour = { + "id": 4, + "name": "Gannie", + "email": "Gannie@you.edu", + "gender": "F" +} +let intFive = { + "id": 5, + "name": "Antonietta", + "email": "Antonietta.edu", + "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(intTwo.name); //? // Kennan's ID From 34a0c50b0315ddb7f21e2e96b18ef22e39986051 Mon Sep 17 00:00:00 2001 From: Arthur Pisakhov Date: Mon, 21 May 2018 17:06:02 -0400 Subject: [PATCH 2/3] completed objects.js --- assignments/objects.js | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/assignments/objects.js b/assignments/objects.js index 0613b2b55..04295fda3 100644 --- a/assignments/objects.js +++ b/assignments/objects.js @@ -19,57 +19,69 @@ let example = { // Write your intern objects here: -let intOne = { +let mitzi = { "id": 1, "name": "Mitzi", - "email": "Mitzi@you.edu", + "email": "mmelloy0@psu.edu", "gender": "F" } -let intTwo = { +let kennan = { "id": 2, "name": "Kennan", - "email": "Kennan@you.edu", - "gender": "M" + "email": "kdiben1@tinypic.com", + "gender": "M", + "speak": function() { + return "Hello, my name is " + kennan.name; + } } -let intThree = { +let keven = { "id": 3, "name": "Keven", - "email": "Keven@you.edu", + "email": "kmummery2@wikimedia.org", "gender": "M" } -let intFour = { +let gannie = { "id": 4, "name": "Gannie", - "email": "Gannie@you.edu", + "email": "gmartinson3@illinois.edu", "gender": "F" } -let intFive = { +let antonietta = { "id": 5, "name": "Antonietta", - "email": "Antonietta.edu", - "gender": "F" + "email": "adaine5@samsung.com", + "gender": "F", + "multiplyNums": function(a,b) { + return a*b; + } } // ==== 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(intTwo.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()); +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(3,4)); // === Great work! === Head over to the the arrays.js file or take a look at the stretch challenge From 6ff13109fc87c46691f4752b0e6e7e12653424f4 Mon Sep 17 00:00:00 2001 From: Arthur Pisakhov Date: Mon, 21 May 2018 17:50:08 -0400 Subject: [PATCH 3/3] completed arrays.js --- assignments/arrays.js | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/assignments/arrays.js b/assignments/arrays.js index c007f3e99..480bb9892 100644 --- a/assignments/arrays.js +++ b/assignments/arrays.js @@ -51,7 +51,7 @@ let inventory = [{"id":1,"car_make":"Lincoln","car_model":"Navigator","car_year" {"id":47,"car_make":"Volkswagen","car_model":"Jetta","car_year":2007}, {"id":48,"car_make":"Dodge","car_model":"Magnum","car_year":2008}, {"id":49,"car_make":"Chrysler","car_model":"Sebring","car_year":1996}, -{"id":50,"car_make":"Lincoln","car_model":"Town Car","car_year":1999}]; +{"id":50,"car_make":"Lincoln","car_model":"Town Car","car_year":1999}] // PROJECT RESTRICTION: You can't use map, reduce, or filter to solve these problems. Only use native JavaScript for loops. @@ -61,36 +61,55 @@ let inventory = [{"id":1,"car_make":"Lincoln","car_model":"Navigator","car_year" // arr[i]; // 1,2,3,4 // } +for(let i = 0; i < inventory.length; i ++) { + inventory[i]; + } + // ==== 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[33].car_year} ${inventory[33].car_make} ${inventory[33].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(); +let lastCar = 49; +console.log(`Last car is a ${inventory[lastCar].car_year} ${inventory[lastCar].car_make} ${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