Skip to content

Commit fad8a32

Browse files
committed
Added object of intern with multiple students in it. Added function to make Kennan speak.
1 parent 86fe720 commit fad8a32

1 file changed

Lines changed: 59 additions & 17 deletions

File tree

‎assignments/objects.js‎

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Let's get some practice writing a few objects for a new group of interns at a small business.
22

3-
// ==== Challenge 1: Writing Objects ====
3+
// ==== Challenge 1: Writing Objects ====
44
// 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:
55

66
// 1,mmelloy0@psu.edu,Mitzi,F
@@ -11,45 +11,87 @@
1111

1212
// Example format of an intern object: 1,examples@you.edu,Example,F
1313
const example = {
14-
"id": 0,
15-
"name": "Example",
16-
"email": "examples@you.edu",
17-
"gender": "F"
18-
}
14+
id: 0,
15+
name: "Example",
16+
email: "examples@you.edu",
17+
gender: "F"
18+
};
1919

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

22-
23-
// ==== Challenge 2: Reading Object Data ====
60+
// ==== Challenge 2: Reading Object Data ====
2461
// Once your objects are created, log out the following requests from HR into the console:
25-
62+
console.log("Student Info Request:");
63+
console.log("Mitzi's name is " + intern.Mitzi.name);
2664
// Mitzi's name
27-
65+
console.log("Kennan's ID is " + intern.Kennan.id);
2866
// Kennan's ID
29-
67+
console.log("Keven's email is " + intern.Keven.email);
3068
// Keven's email
31-
69+
console.log("Gannie's name is " + intern.Gannie.name);
3270
// Gannie's name
33-
71+
console.log("Antonietta's gender is " + intern.Antonietta.gender);
3472
// Antonietta's Gender
3573

36-
// ==== Challenge 3: Object Methods ====
74+
// ==== Challenge 3: Object Methods ====
3775
// Give Kennan the ability to say "Hello, my name is Kennan!" Use the console.log provided as a hint.
3876
// console.log(kennan.speak());
39-
77+
intern.Kennan.speak = function() {
78+
var hello = "Hello, my name is Kennan!";
79+
return hello;
80+
};
81+
console.log(intern.Kennan.speak());
4082
// Antonietta loves math, give her the ability to multiply two numbers together and return the product. Use the console.log provided as a hint.
4183
//console.log(antonietta.multiplyNums(3,4));
4284

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

45-
// ==== Stretch Challenge: Nested Objects and the this keyword ====
87+
// ==== Stretch Challenge: Nested Objects and the this keyword ====
4688

4789
// 1. Create a parent object with properties for name and age. Make the name Susan and the age 70.
4890
// 2. Nest a child object in the parent object with name and age as well. The name will be George and the age will be 50.
4991
// 3. Nest a grandchild object in the child object with properties for name and age. The name will be Sam and the age will be 30
5092
// 4. Give each of the objects the ability to speak their names using the this keyword.
5193

52-
const parent = {}
94+
const parent = {};
5395

5496
// Log the parent object's name
5597

0 commit comments

Comments
 (0)