-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
practice.js
129 lines (93 loc) · 3.49 KB
/
practice.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
Once you complete a problem, refresh ./SpecRunner.html in your browser and check to see if the problem's test(s) are passing.
Passed tests will be indicated by a green circle.
Failed tests will be indicated by a red X.
You can refresh the page at any time to re-run all the tests.
*/
////////// PROBLEM 1 //////////
/*
Create an object called me.
Give it a key of name with the value being your name, and another key of age with the value being your age.
Then alert your name using dot notation.
*/
//Code here
////////// PROBLEM 2 //////////
/*
Make a 'favoriteThings' object that contains the following keys: band, food, person, book, movie, holiday.
Have the values to those keys be strings that are equal to your favorite thing in that category.
*/
//Code here
/*
After you've made your object, use bracket or dot notation to add another key named 'car' with the value being your favorite car
and then another key named 'brand' with the value being your favorite brand.
*/
//Code here
/*
Now use bracket or dot notation to change the value of the food key in your favoriteThings object to be 'Chicken Nuggets'
and change the value of the book key in your favoriteThings object to be 'Harry Potter'.
*/
//Code here
////////// PROBLEM 3 //////////
/*
Create an empty Object called backPack.
Now, create a variable called item and set it equal to the string 'firstPocket'.
Using bracket notation and the item variable, add a 'firstPocket' key (or property) to backPack.
Set the value of that key to 'chapstick'.
Using dot notation, add another key (or property) to your backPack object that is named color, with the value being the color of your backpack.
*/
//Code here
/*
After you do the above, alert your entire backPack object.
*/
//Code here
/*
You probably noticed that it just alerted [object Object].
Alerting to see the data in your Object doesn't work so well.
Instead, console.log your whole backPack object and then check out the console.
*/
//Code here
////////// PROBLEM 4 //////////
// Do not edit the code below.
var user2 = {
name: 'Bryan',
age: 24,
pwHash: 'U+Ldlngx2BYQk',
email: '[email protected]',
birthday: '05/02/1990',
username: 'bryansmith33'
};
// Do not edit the code above.
/*
Let's say I, the user, decided to change my name and email address to the following:
name -> 'Bryan G. Smith' and email -> '[email protected]'.
Make that change without modifying the original object code above.
*/
//Code Here
/////////////////////// EXTRA PRACTICE PROBLEMS BELOW ////////////////////
////////// MOVE ONTO NEXT SECTION BEFORE WORKING ON THESE ////////////////
////////// PROBLEM 5 //////////
/*
Create an empty object called methodCollection.
*/
//Code Here
/*
Now add two methods (functions that are properties on objects) to your methodCollection object.
One called 'alertHello' which alerts 'hello' and another method called 'logHello' which logs 'hello' to the console.
*/
//Code Here
/*
Now call your alertHello and logHello methods.
*/
//Code Here
////////// PROBLEM 6 //////////
/*
Create a function called makePerson which takes in name, birthday, ssn as its parameters.
Return a new object with all of the information that you passed in.
*/
//Code Here
////////// PROBLEM 7 //////////
/*
Create a function called makeCard which takes in cardNumber, expirationDate, and securityCode to make a Credit Card object.
Return that object so that whenever you invoke makeCard, you get a brand new credit card.
*/
//Code Here