Skip to content

Commit 72d7f13

Browse files
author
[Arin Ramer]
committed
Finished
1 parent d5d5a4a commit 72d7f13

3 files changed

Lines changed: 99 additions & 26 deletions

File tree

‎assignments/arrays.js‎

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,30 +75,58 @@ let inventory = [
7575

7676
// ==== Challenge 1 ====
7777
// 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:
78-
console.log(`Car 33 is a *car year goes here* *car make goes here* *car model goes here*`);
78+
console.log('Car 33 is a ' + inventory[32].car_year + ' ' + inventory[32].car_make + ' ' + inventory[32].car_model + '.');
7979

8080
// ==== Challenge 2 ====
8181
// 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.
8282
let lastCar = 0;
83-
console.log();
83+
84+
for (let i = 0; i < inventory.length; i++){
85+
if (inventory[i] === inventory[inventory.length - 1]){
86+
console.log(inventory[i]);
87+
}
88+
}
8489

8590
// ==== Challenge 3 ====
8691
// 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
8792
let carModels = [];
88-
let carModelsSorted = [];
89-
console.log();
93+
94+
for (let i = 0; i < inventory.length; i++){
95+
let models = inventory[i].car_model;
96+
carModels.push(models);
97+
carModels.sort();
98+
console.log(carModels);
99+
}
90100

91101
// ==== Challenge 4 ====
92102
// 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.
93103
let carYears = [];
94-
console.log();
104+
105+
for (let i = 0; i < inventory.length; i++){
106+
const year = inventory[i].car_year;
107+
carYears.push(year);
108+
console.log(carYears);
109+
}
95110

96111
// ==== Challenge 5 ====
97112
// 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.
98113
let oldCars = [];
99-
console.log();
114+
115+
for (let i = 0; i < inventory.length; i++){
116+
const year = inventory[i].car_year;
117+
if (year < 2000) {
118+
oldCars.push(year);
119+
console.log(oldCars);
120+
}
121+
}
100122

101123
// ==== Challenge 6 ====
102124
// 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.
103-
let BMWAndAudi = [];
104-
console.log();
125+
let BMWAndAudi =[];
126+
127+
for (let i = 0; i < inventory.length; i++){
128+
if (inventory[i].car_make === 'BMW' || inventory[i].car_make === 'Audi'){
129+
BMWAndAudi.push(inventory[i]);
130+
console.log(BMWAndAudi);
131+
}
132+
}

‎assignments/function-conversion.js‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
// Take the commented ES5 syntax and convert it to ES6 arrow Syntax
22

3-
// let myFunction = function () {
4-
// console.log("Function was invoked!");
5-
// };
6-
// myFunction();
3+
let myFunction = ()=> {
4+
console.log("Function was invoked!");
5+
};
6+
myFunction();
77

8-
// let anotherFunction = function (param) {
9-
// return param;
10-
// };
11-
// anotherFunction("Example");
8+
let anotherFunction = (param)=> {
9+
return param;
10+
};
11+
anotherFunction("Example");
1212

13-
// let add = function (param1, param2) {
14-
// return param1 + param2;
15-
// };
16-
// add(1,2);
13+
let add = (param1, param2)=> {
14+
return param1 + param2;
15+
};
16+
add(1,2);
1717

18-
// let subtract = function (param1, param2) {
19-
// return param1 - param2;
20-
// };
21-
// subtract(1,2);
18+
let subtract = (param1, param2)=> {
19+
return param1 - param2;
20+
};
21+
subtract(1,2);
2222

2323

2424
// Stretch

‎assignments/objects.js‎

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

2020
// Write your intern objects here:
21+
const Mitzi = {
22+
id: 1,
23+
name: "Mitzi",
24+
email: "mmelloy0@psu.edu",
25+
gender: "F",
26+
}
27+
28+
const Kennan = {
29+
id: 2,
30+
name: "Kennan",
31+
email: "kdiben1@tinypic.com",
32+
gender: "M",
33+
speak : function() {
34+
return "Hello, my name is " + this.name;
35+
}
36+
}
2137

38+
const Keven = {
39+
id: 3,
40+
name: "Keven",
41+
email: "kmummery2@wikimedia.org",
42+
gender: "M",
43+
}
44+
45+
const Gannie = {
46+
id: 4,
47+
name: "Gannie",
48+
email: "mmelloy0@psu.edu",
49+
gender: "M",
50+
}
51+
52+
const Antonietta = {
53+
id: 5,
54+
name: "Antonietta",
55+
email: "mmelloy0@psu.edu",
56+
gender: "F",
57+
multiplyNums : function(num1, num2) {
58+
return num1 * num2;
59+
}
60+
}
2261

2362
// ==== Challenge 2: Reading Object Data ====
2463
// Once your objects are created, log out the following requests from HR into the console:
@@ -33,12 +72,18 @@ const example = {
3372

3473
// Antonietta's Gender
3574

75+
console.log(Mitzi.name);
76+
console.log(Kennan.id);
77+
console.log(Keven.email);
78+
console.log(Gannie.name);
79+
console.log(Antonietta.gender);
80+
3681
// ==== Challenge 3: Object Methods ====
3782
// Give Kennan the ability to say "Hello, my name is Kennan!" Use the console.log provided as a hint.
38-
// console.log(kennan.speak());
83+
console.log(Kennan.speak());
3984

4085
// 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));
86+
console.log(Antonietta.multiplyNums(3,4));
4287

4388
// === 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.
4489

0 commit comments

Comments
 (0)