You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 457dcc4
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: assignments/arrays.js
+39-7Lines changed: 39 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -63,32 +63,64 @@ let inventory = [{"id":1,"car_make":"Lincoln","car_model":"Navigator","car_year"
63
63
64
64
// ==== Challenge 1 ====
65
65
// 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(inventory[32]);
67
67
68
68
// ==== Challenge 2 ====
69
69
// 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.
70
70
letlastCar=0;
71
-
console.log();
71
+
console.log(inventory.slice(-1)[0]);
72
72
73
73
// ==== Challenge 3 ====
74
74
// 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
// 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.
103
+
letresult=inventory.map(a=>a.car_year);
80
104
letcarYears=[];
81
-
console.log();
105
+
result.sort()
106
+
console.log(result);
82
107
83
108
// ==== Challenge 5 ====
84
109
// 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.
85
110
letoldCars=[];
86
-
console.log();
111
+
112
+
oldCars=result.slice(25,100)
113
+
console.log(oldCars);
87
114
88
115
// ==== Challenge 6 ====
89
116
// 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.
Copy file name to clipboardExpand all lines: assignments/objects.js
+40-10Lines changed: 40 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -4,8 +4,8 @@
4
4
// HR needs some information on the new interns put into a database. Given an id, email, first name, and gender. Create an object for each person in the company list:
5
5
6
6
// 1,mmelloy0@psu.edu,Mitzi,F
7
-
// 2,kdiben1@tinypic.com,Kennan,M
8
-
// 3,kmummery2@wikimedia.org,Keven,M
7
+
// 2,kdiben1@tinypic.com,,M
8
+
// 3,kmummery2@wikimedia.org,,M
9
9
// 4,gmartinson3@illinois.edu,Gannie,M
10
10
// 5,adaine5@samsung.com,Antonietta,F
11
11
@@ -18,28 +18,58 @@ const example = {
18
18
}
19
19
20
20
// Write your intern objects here:
21
-
21
+
constintern1={
22
+
"id": 0,
23
+
"name": "Mitzi",
24
+
"email": "mmelloy0@psu.edu",
25
+
"gender": "F"
26
+
}
27
+
constintern2={
28
+
"id": 1,
29
+
"name": "Kennan",
30
+
"email": "kdiben1@tinypic.com",
31
+
"gender": "M"
32
+
}
33
+
constintern3={
34
+
"id": 2,
35
+
"name": "Keven",
36
+
"email": "kmummery2@wikimedia.org",
37
+
"gender": "M"
38
+
}
39
+
constintern4={
40
+
"id": 3,
41
+
"name": "Gannie",
42
+
"email": "gmartinson3@illinois.edu",
43
+
"gender": "M"
44
+
}
45
+
constintern5={
46
+
"id": 4,
47
+
"name": "Antonietta",
48
+
"email": "adaine5@samsung.com",
49
+
"gender": "M"
50
+
}
22
51
23
52
// ==== Challenge 2: Reading Object Data ====
24
53
// Once your objects are created, log out the following requests from HR into the console:
25
54
26
55
// Mitzi's name
27
-
56
+
console.log(intern1.name)
28
57
// Kennan's ID
29
-
58
+
console.log(intern2.id)
30
59
// Keven's email
31
-
60
+
console.log(intern3.email)
32
61
// Gannie's name
33
-
62
+
console.log(intern4.name)
34
63
// Antonietta's Gender
35
-
64
+
console.log(intern5.gender)
36
65
// ==== Challenge 3: Object Methods ====
37
66
// Give Kennan the ability to say "Hello, my name is Kennan!" Use the console.log provided as a hint.
38
-
// console.log(kennan.speak());
67
+
68
+
console.log("hello my name is ",intern2.name);
39
69
40
70
// 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
71
//console.log(antonietta.multiplyNums(3,4));
42
-
72
+
console.log("hello i can add and my name is",intern4.name,3*4)
43
73
// === Great work! === Head over to the the arrays.js file or take a look at the stretch challenge
44
74
45
75
// ==== Stretch Challenge: Nested Objects and the this keyword ====
0 commit comments