Skip to content

Commit 2e6350e

Browse files
committed
everything complete attempting the stretch though
1 parent dfb3da7 commit 2e6350e

1 file changed

Lines changed: 60 additions & 9 deletions

File tree

‎assignments/objects.js‎

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
// 3,kmummery2@wikimedia.org,Keven,M
99
// 4,gmartinson3@illinois.edu,Gannie,M
1010
// 5,adaine5@samsung.com,Antonietta,F
11+
const data = [[1,'mmelloy0@psu.edu','Mitzi','F'],
12+
[2,'kdiben1@tinypic.com','Kennan','M'],
13+
[3,'kmummery2@wikimedia.org','Keven','M'],
14+
[4,'gmartinson3@illinois.edu','Gannie','M'],
15+
[5,'adaine5@samsung.com','Antonietta','F']]
1116

1217
// Example format of an intern object: 1,examples@you.edu,Example,F
1318
let example = {
@@ -18,27 +23,61 @@ let example = {
1823
}
1924

2025
// Write your intern objects here:
21-
26+
const newInterns = {mitzi, kennan, keven, gannie, antonietta}
27+
// for(d in data){
28+
// newObject = {}
29+
// newObject.id = data[d][0];
30+
// newObject.email = data[d][1];
31+
// newObject.name = data[d][2];
32+
// newObject.gender = data[d][3];
33+
// console.log(newObject);
34+
// }
35+
// console.log(newInterns);
36+
const mitzi = { id: 1, email: 'mmelloy0@psu.edu', name: 'Mitzi', gender: 'F' }
37+
const kennan ={ id: 2,
38+
email: 'kdiben1@tinypic.com',
39+
name: 'Kennan',
40+
gender: 'M' }
41+
const keven = { id: 3,
42+
email: 'kmummery2@wikimedia.org',
43+
name: 'Keven',
44+
gender: 'M' }
45+
const gannie = { id: 4,
46+
email: 'gmartinson3@illinois.edu',
47+
name: 'Gannie',
48+
gender: 'M' }
49+
const antonietta = { id: 5,
50+
email: 'adaine5@samsung.com',
51+
name: 'Antonietta',
52+
gender: 'F' }
2253

2354
// ==== Challenge 2: Reading Object Data ====
2455
// Once your objects are created, log out the following requests from HR into the console:
2556

2657
// Mitzi's name
27-
58+
console.log(mitzi.name);
2859
// Kennan's ID
29-
60+
console.log(kennan.id);
3061
// Keven's email
62+
console.log(keven.email);
3163

3264
// Gannie's name
65+
console.log(gannie.name);
3366

3467
// Antonietta's Gender
35-
68+
console.log(antonietta.gender);
3669
// ==== Challenge 3: Object Methods ====
3770
// Give Kennan the ability to say "Hello, my name is Kennan!" Use the console.log provided as a hint.
38-
// console.log(kennan.speak());
71+
const letSpeak = function() { return `Hello, my name is ${this.name}!`; }
72+
kennan.speak = letSpeak;
73+
74+
console.log(kennan.speak());
3975

4076
// Antonietta loves math, give her the ability to multiply two numbers together and return the product. Use the console.log provided as a hint.
4177
//console.log(antonietta.multiplyNums(3,4));
78+
const letMultiply = function(x,y) {return x*y;}
79+
antonietta.multiplyNums = letMultiply;
80+
console.log(antonietta.multiplyNums(3,4));
4281

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

@@ -50,15 +89,27 @@ let example = {
5089
// 4. Give each of the objects the ability to speak their names using the this keyword.
5190

5291
let parent = {}
92+
parent.name = 'Susan';
93+
parent.age = 70;
5394

54-
// Log the parent object's name
95+
parent.child = {}
96+
parent.child.name = 'George';
97+
parent.child.age = 50;
98+
parent.child.grandchild = {};
99+
parent.child.grandchild.name = 'Sam';
100+
parent.child.grandchild.age = 30;
55101

56-
// Log the child's age
57102

58-
// Log the name and age of the grandchild
59103

104+
// Log the parent object's name
105+
console.log(parent.name);
106+
// Log the child's age
107+
console.log(parent.child.age);
108+
// Log the name and age of the grandchild
109+
console.log(parent.child.grandchild.name,parent.child.grandchild.age);
60110
// Have the parent speak
61111

112+
62113
// Have the child speak
63114

64-
// Have the grandchild speak
115+
// Have the grandchild speak

0 commit comments

Comments
 (0)