Skip to content

Commit bf7680c

Browse files
committed
Jake Henry added project 3 Wip
1 parent 577cf72 commit bf7680c

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/project-3.js

+31
Original file line numberDiff line numberDiff line change
@@ -5,68 +5,99 @@ const makeCat = (name, age) => {
55
// add an age property to the object with the value set to the age argument
66
// add a method called meow that returns the string 'Meow!'
77
// return the object
8+
const cat = {
9+
age,
10+
name,
11+
meow() {
12+
return 'Meow!';
13+
}
14+
};
15+
return cat;
816
};
917

1018
const addProperty = (object, property) => {
1119
// add the property to the object with a value of null
1220
// return the object
1321
// note: the property name is NOT 'property'. The name is the value of the argument called property (a string)
22+
object[property] = null;
23+
return object;
1424
};
1525

1626
const invokeMethod = (object, method) => {
1727
// method is a string that contains the name of a method on the object
1828
// invoke this method
1929
// nothing needs to be returned
30+
object[method]();
2031
};
2132

2233
const multiplyMysteryNumberByFive = (mysteryNumberObject) => {
2334
// mysteryNumberObject has a property called mysteryNumber
2435
// multiply the mysteryNumber property by 5 and return the product
36+
const product = mysteryNumberObject.mysteryNumber * 5;
37+
return product;
2538
};
2639

2740
const deleteProperty = (object, property) => {
2841
// remove the property from the object
2942
// return the object
43+
delete object[property];
44+
return object;
3045
};
3146

3247
const newUser = (name, email, password) => {
3348
// create a new object with properties matching the arguments passed in.
3449
// return the new object
50+
const obj = { name, email, password };
51+
return obj;
3552
};
3653

3754
const hasEmail = (user) => {
3855
// return true if the user has a value for the property 'email'
3956
// otherwise return false
57+
if (user.email) { return true; }
58+
return false;
4059
};
4160

4261
const hasProperty = (object, property) => {
4362
// return true if the object has the value of the property argument
4463
// property is a string
4564
// otherwise return false
65+
if (Object.prototype.hasOwnProperty.call(object, property)) { return true; }
66+
return false;
4667
};
4768

4869
const verifyPassword = (user, password) => {
4970
// check to see if the provided password matches the password property on the user object
5071
// return true if they match
5172
// otherwise return false
73+
if (password === user.password) { return true; }
74+
return false;
5275
};
5376

5477
const updatePassword = (user, newPassword) => {
5578
// replace the existing password on the user object with the value of newPassword
5679
// return the object
80+
user.password = newPassword;
81+
return user;
5782
};
5883

5984
const addFriend = (user, newFriend) => {
6085
// user has a property called friends that is an array
6186
// add newFriend to the end of the friends array
6287
// return the user object
88+
user.friends.push(newFriend);
89+
return user;
6390
};
6491

6592
const setUsersToPremium = (users) => {
6693
// users is an array of user objects.
6794
// each user object has the property 'isPremium'
6895
// set each user's isPremium property to true
6996
// return the users array
97+
users.forEach((item) => {
98+
item.isPremium = true;
99+
});
100+
return users;
70101
};
71102

72103
const sumUserPostLikes = (user) => {

0 commit comments

Comments
 (0)