Skip to content

Commit 0a9f3e2

Browse files
committed
halfway done
1 parent bb0566a commit 0a9f3e2

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/project-3.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ const addProperty = (object, property) => {
1111
// add the property to the object with a value of null
1212
// return the object
1313
// note: the property name is NOT 'property'. The name is the value of the argument called property (a string)
14+
object[property] = null;
15+
return object;
1416
};
1517

1618
const invokeMethod = (object, method) => {
@@ -22,6 +24,7 @@ const invokeMethod = (object, method) => {
2224
const multiplyMysteryNumberByFive = (mysteryNumberObject) => {
2325
// mysteryNumberObject has a property called mysteryNumber
2426
// multiply the mysteryNumber property by 5 and return the product
27+
return mysteryNumberObject.mysteryNumber * 5;
2528
};
2629

2730
const deleteProperty = (object, property) => {
@@ -32,6 +35,8 @@ const deleteProperty = (object, property) => {
3235
const newUser = (name, email, password) => {
3336
// create a new object with properties matching the arguments passed in.
3437
// return the new object
38+
const newObj = { name, email, password };
39+
return newObj;
3540
};
3641

3742
const hasEmail = (user) => {
@@ -43,6 +48,10 @@ const hasProperty = (object, property) => {
4348
// return true if the object has the value of the property argument
4449
// property is a string
4550
// otherwise return false
51+
if (object[property]) {
52+
return true;
53+
}
54+
return false;
4655
};
4756

4857
const verifyPassword = (user, password) => {
@@ -54,6 +63,8 @@ const verifyPassword = (user, password) => {
5463
const updatePassword = (user, newPassword) => {
5564
// replace the existing password on the user object with the value of newPassword
5665
// return the object
66+
user.password = newPassword;
67+
return user;
5768
};
5869

5970
const addFriend = (user, newFriend) => {
@@ -67,6 +78,10 @@ const setUsersToPremium = (users) => {
6778
// each user object has the property 'isPremium'
6879
// set each user's isPremium property to true
6980
// return the users array
81+
for (let i = 0; i < users.length; i++) {
82+
users[i].isPremium = true;
83+
}
84+
return users;
7085
};
7186

7287
const sumUserPostLikes = (user) => {
@@ -85,6 +100,10 @@ const addCalculateDiscountPriceMethod = (storeItem) => {
85100
// price -> 20
86101
// discountPercentage -> .2
87102
// discountPrice = 20 - (20 * .2)
103+
storeItem.calculateDiscountPrice = function calculate() {
104+
return (storeItem.price - (storeItem.price * storeItem.discountPercentage));
105+
};
106+
return storeItem;
88107
};
89108

90109
// Do not modify code below this line.

0 commit comments

Comments
 (0)