Skip to content

Commit 2d44c5c

Browse files
committed
completed objects assignment
1 parent df12804 commit 2d44c5c

1 file changed

Lines changed: 70 additions & 15 deletions

File tree

assignments/objects.js

Lines changed: 70 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
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 ====
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:
3+
// ==== Challenge 1: Writing Objects ====
4+
// HR needs some information on the new interns put into a database.
5+
// Given an id, email, first name, and gender.
6+
// Create an object for each person in the company list:
57

68
// 1,[email protected],Mitzi,F
79
// 2,[email protected],Kennan,M
@@ -11,45 +13,98 @@
1113

1214
// Example format of an intern object: 1,[email protected],Example,F
1315
const example = {
14-
"id": 0,
15-
"name": "Example",
16-
"email": "[email protected]",
17-
"gender": "F"
18-
}
16+
id: 0,
17+
name: "Example",
18+
19+
gender: "F"
20+
};
1921

2022
// Write your intern objects here:
2123

22-
23-
// ==== Challenge 2: Reading Object Data ====
24+
const intern1 = {
25+
id: 1,
26+
name: "Mitzi",
27+
28+
gender: "F"
29+
};
30+
31+
const intern2 = {
32+
id: 2,
33+
name: "Kennan",
34+
35+
gender: "M",
36+
speak: function() {
37+
console.log("Hello, my name is Kennan!");
38+
}
39+
};
40+
41+
const intern3 = {
42+
id: 3,
43+
name: "Keven",
44+
45+
gender: "M"
46+
};
47+
48+
const intern4 = {
49+
id: 4,
50+
name: "Gannie",
51+
52+
gender: "M"
53+
};
54+
55+
const intern5 = {
56+
id: 5,
57+
name: "Antonietta",
58+
59+
gender: "F",
60+
theMaths: function(num1, num2) {
61+
console.log(num1 * num2);
62+
}
63+
};
64+
65+
// ==== Challenge 2: Reading Object Data ====
2466
// Once your objects are created, log out the following requests from HR into the console:
2567

2668
// Mitzi's name
69+
console.log(intern1.name);
2770

2871
// Kennan's ID
72+
console.log(intern2.name);
2973

3074
// Keven's email
75+
console.log(intern3.email);
3176

3277
// Gannie's name
78+
console.log(intern4.name);
3379

3480
// Antonietta's Gender
81+
console.log(intern5.gender);
3582

36-
// ==== Challenge 3: Object Methods ====
83+
// ==== Challenge 3: Object Methods ====
3784
// Give Kennan the ability to say "Hello, my name is Kennan!" Use the console.log provided as a hint.
85+
86+
intern2.speak();
87+
3888
// console.log(kennan.speak());
3989

40-
// Antonietta loves math, give her the ability to multiply two numbers together and return the product. Use the console.log provided as a hint.
90+
// Antonietta loves math, give her the ability to multiply two numbers together and return the product.
91+
// Use the console.log provided as a hint.
4192
//console.log(antonietta.multiplyNums(3,4));
4293

94+
intern5.theMaths(2, 5);
95+
4396
// === Great work! === Head over to the the arrays.js file or take a look at the stretch challenge
4497

45-
// ==== Stretch Challenge: Nested Objects and the this keyword ====
98+
// ==== Stretch Challenge: Nested Objects and the this keyword ====
4699

47100
// 1. Create a parent object with properties for name and age. Make the name Susan and the age 70.
48-
// 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.
49-
// 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
101+
// 2. Nest a child object in the parent object with name and age as well.
102+
// The name will be George and the age will be 50.
103+
// 3. Nest a grandchild object in the child object with properties for name and age.
104+
// The name will be Sam and the age will be 30
50105
// 4. Give each of the objects the ability to speak their names using the this keyword.
51106

52-
const parent = {}
107+
const parent = {};
53108

54109
// Log the parent object's name
55110

0 commit comments

Comments
 (0)