Skip to content

Commit 8af564d

Browse files
author
Sascha
committed
added the object.js challenge answers as well as halve of array.js
1 parent 86fe720 commit 8af564d

9 files changed

Lines changed: 288 additions & 6 deletions

File tree

‎.idea/JavaScript-I.iml‎

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/misc.xml‎

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/modules.xml‎

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/vcs.xml‎

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/workspace.xml‎

Lines changed: 159 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.vscode/tasks.json‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"version": "0.1.0",
3+
"command": "node",
4+
"isShellCommand": true,
5+
"args": [
6+
"--harmony"
7+
],
8+
9+
"tasks": [
10+
{
11+
"taskName": "runFile",
12+
"suppressTaskName": true,
13+
"showOutput": "always",
14+
"problemMatcher": "$jshint",
15+
"args": ["${file}"]
16+
}
17+
]
18+
}

‎assignments/.vscode/tasks.json‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"version": "0.1.0",
3+
"command": "node",
4+
"isShellCommand": true,
5+
"args": [
6+
"--harmony"
7+
],
8+
9+
"tasks": [
10+
{
11+
"taskName": "runFile",
12+
"suppressTaskName": true,
13+
"showOutput": "always",
14+
"problemMatcher": "$jshint",
15+
"args": ["${file}"]
16+
}
17+
]
18+
}

‎assignments/arrays.js‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,29 @@ let inventory = [{"id":1,"car_make":"Lincoln","car_model":"Navigator","car_year"
6363

6464
// ==== Challenge 1 ====
6565
// 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:
66-
console.log(`Car 33 is a *car year goes here* *car make goes here* *car model goes here*` );
66+
console.log(`Car 33 is a ${inventory[32].car_year} ${inventory[32].car_make} ${inventory[32].car_model}`);
6767

6868
// ==== Challenge 2 ====
6969
// 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.
7070
let lastCar = 0;
71-
console.log();
71+
console.log(`The last car in the invetory is a ${inventory[inventory.length -1].car_make} ${inventory[inventory.length -1].car_model}`);
7272

7373
// ==== Challenge 3 ====
7474
// 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
7575
let carModels = [];
76-
console.log();
76+
for (let i = 0; i < inventory.length; i++) {
77+
carModels.push(inventory[i].car_model); // 1,2,3,4
78+
}
79+
carModels.sort();
80+
console.log(carModels);
7781

7882
// ==== Challenge 4 ====
7983
// 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.
8084
let carYears = [];
81-
console.log();
85+
for (let i = 0; i < inventory.length; i++) {
86+
carYears.push(inventory[i].car_year); // 1,2,3,4
87+
}
88+
console.log(carYears);
8289

8390
// ==== Challenge 5 ====
8491
// 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.

‎assignments/objects.js‎

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,75 @@ const example = {
1818
}
1919

2020
// Write your intern objects here:
21+
const internOne = {
22+
"id": 1,
23+
"name": "Mitzi",
24+
"email": "mmelloy0@psu.edu",
25+
"gender": "F"
26+
}
27+
28+
const internTwo = {
29+
"id": 2,
30+
"name": "Kennan",
31+
"email": "kdiben1@tinypic.com",
32+
"gender": "M"
33+
}
34+
35+
const internThree = {
36+
"id": 3,
37+
"name": "Keven",
38+
"email": "kmummery2@wikimedia.org",
39+
"gender": "M"
40+
}
41+
42+
const internFour = {
43+
"id": 4,
44+
"name": "Gannie",
45+
"email": "gmartinson3@illinois.edu",
46+
"gender": "M"
47+
}
48+
49+
const internFive = {
50+
"id": 5,
51+
"name": "Antonietta",
52+
"email": "adaine5@samsung.com",
53+
"gender": "F"
54+
}
2155

2256

2357
// ==== Challenge 2: Reading Object Data ====
2458
// Once your objects are created, log out the following requests from HR into the console:
2559

2660
// Mitzi's name
61+
console.log(internOne.name);
2762

2863
// Kennan's ID
64+
console.log(internTwo.id);
2965

3066
// Keven's email
67+
console.log(internThree.email);
3168

3269
// Gannie's name
70+
console.log(internFour.name);
3371

3472
// Antonietta's Gender
73+
console.log(internFive.gender);
74+
3575

3676
// ==== Challenge 3: Object Methods ====
3777
// Give Kennan the ability to say "Hello, my name is Kennan!" Use the console.log provided as a hint.
38-
// console.log(kennan.speak());
78+
internTwo.speak = function() {
79+
return `Hello, my name is ${this.name}!`
80+
}
81+
82+
console.log(internTwo.speak());
3983

4084
// Antonietta loves math, give her the ability to multiply two numbers together and return the product. Use the console.log provided as a hint.
41-
//console.log(antonietta.multiplyNums(3,4));
85+
internFive.multiplyNums = function(num1, num2) {
86+
return num1 * num2
87+
}
88+
89+
console.log(internFive.multiplyNums(3,4));
4290

4391
// === Great work! === Head over to the the arrays.js file or take a look at the stretch challenge
4492

0 commit comments

Comments
 (0)