-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobj_beginners.js
84 lines (71 loc) · 1.7 KB
/
obj_beginners.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Example
var ourDog = {
"name": "Camper",
"legs": 4,
"tails": 1,
"friends": ["everything!"]
};
// Only change code below this line.
var myDog = {
"name": "Puppy",
"legs": 4,
"tails": 1,
"friends": ["Wendy Williams", "Shehnaynai", "Cardigan"]
};
/*
var myDog = "Hunter";
var dogs = {
Fido: "Mutt",
Hunter: "Doberman",
Snoopie: "Beagle"
}
var breed = dogs[myDog]; // "Hunter"
console.log(breed)// "Doberman"
*/
//INSTRUCTIONS
//Use the playerNumber variable to lookup player 16 in testObj using bracket notation.
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};
// Only change code below this line;
var playerNumber = 16; // Change this Line
var player = testObj[playerNumber]; // Change this Line
//INSTRUCTIONS
/* Update the myDog object's name property.
Let's change her name from "Coder" to "Happy Coder".
You can use either dot or bracket notation. */
var myDog = {
"name": "Coder",
"legs": 4,
"tails": 1,
"friends": ["Free Code Camp Campers"]
};
// Only change code below this line.
myDog["name"] = "Happy Coder";
//INSTRUCTIONS
/* Add a "bark" property to myDog and set it to a dog sound, such as "woof".
You may use either dot or bracket notation. */
var myDog = {
"name": "Happy Coder",
"legs": 4,
"tails": 1,
"friends": ["Free Code Camp Campers"]
};
// Only change code below this line.
myDog.bark = "woof";
//INSTRUCTIONS
//Delete the "tails" property from myDog. You may use either dot or bracket notation.
var myDog = {
"name": "Happy Coder",
"legs": 4,
"tails": 1,
"friends": ["Free Code Camp Campers"],
"bark": "woof"
};
console.log("Before: ", myDog);
// Only change code below this line.
delete myDog.tails;
//TO TEST
console.info ("After Delete: ", myDog);