Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment added for clarity to README.md #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* dot notation vs bracket notation


2. Fork and clone this repo. When you need to commit use the following commands.
2. Fork and clone this repo. When you need to commit, use the following commands.

* git status
* git add --all
Expand Down
129 changes: 68 additions & 61 deletions exercises.js
Original file line number Diff line number Diff line change
@@ -1,110 +1,117 @@
'use strict';
//'use strict';

//Do not change any of the function names

function makeCat(name, age) {
//create a new object with a name property with the value set to the name argument
//add an age property to the object with the value set to the age argument
//add a method called meow that returns the string 'Meow!'
//return the object
//create a new object with a name property with the value set to the name argument
//add an age property to the object with the value set to the age argument
//add a method called meow that returns the string 'Meow!'
//return the object
return {
name: name,
age: age,
meow: function() {
return 'Meow!';
}
};
}

function addProperty(object, property) {
//add the property to the object with a value of null
//return the object
//note: the property name is NOT 'property'. The name is the value of the argument called property (a string)
//add the property to the object with a value of null
//return the object
//note: the property name is NOT 'property'. The name is the value of the argument called property (a string)
}

function invokeMethod(object, method) {
//method is a string that contains the name of a method on the object
//invoke this method
//nothing needs to be returned
//method is a string that contains the name of a method on the object
//invoke this method
//nothing needs to be returned
}

function multiplyMysteryNumberByFive(mysteryNumberObject) {
//mysteryNumberObject has a property called mysteryNumber
//multiply the mysteryNumber property by 5 and return the product
//mysteryNumberObject has a property called mysteryNumber
//multiply the mysteryNumber property by 5 and return the product
}

function deleteProperty(object, property) {
//remove the property from the object
//return the object
//remove the property from the object
//return the object
}

function newUser(name, email, password) {
//create a new object with properties matching the arguments passed in.
//return the new object
//create a new object with properties matching the arguments passed in.
//return the new object
}

function hasEmail(user) {
//return true if the user has a value for the property 'email'
//otherwise return false
//return true if the user has a value for the property 'email'
//otherwise return false
}

function hasProperty(object, property) {
//return true if the object has the value of the property argument
//property is a string
//otherwise return false
//return true if the object has the value of the property argument
//property is a string
//otherwise return false
}

function verifyPassword(user, password) {
//check to see if the provided password matches the password property on the user object
//return true if they match
//otherwise return false
//check to see if the provided password matches the password property on the user object
//return true if they match
//otherwise return false
}

function updatePassword(user, newPassword) {
//replace the existing password on the user object with the value of newPassword
//return the object
//replace the existing password on the user object with the value of newPassword
//return the object
}

function addFriend(user, newFriend) {
//user has a property called friends that is an array
//add newFriend to the end of the friends array
//return the user object
//user has a property called friends that is an array
//add newFriend to the end of the friends array
//return the user object
}

function setUsersToPremium(users) {
//users is an array of user objects.
//each user object has the property 'isPremium'
//set each user's isPremium property to true
//return the users array
//users is an array of user objects.
//each user object has the property 'isPremium'
//set each user's isPremium property to true
//return the users array
}

function sumUserPostLikes(user) {
//user has an array property called 'posts'
//posts is an array of post objects
//each post object has an integer property called 'likes'
//sum together the likes from all the post objects
//return the sum
//user has an array property called 'posts'
//posts is an array of post objects
//each post object has an integer property called 'likes'
//sum together the likes from all the post objects
//return the sum
}

function addCalculateDiscountPriceMethod(storeItem) {
//add a method to the storeItem object called 'calculateDiscountPrice'
//this method should multiply the storeItem's 'price' and 'discountPercentage' to get the discount
//the method then subtracts the discount from the price and returns the discounted price
//example:
//price -> 20
//discountPercentage -> .2
//discountPrice = 20 - (20 * .2)
//add a method to the storeItem object called 'calculateDiscountPrice'
//this method should multiply the storeItem's 'price' and 'discountPercentage' to get the discount
//the method then subtracts the discount from the price and returns the discounted price
//example:
//price -> 20
//discountPercentage -> .2
//discountPrice = 20 - (20 * .2)
}

//Do not modify code below this line.
////--------------------------------

module.exports = {
makeCat: makeCat,
addProperty: addProperty,
invokeMethod: invokeMethod,
multiplyMysteryNumberByFive: multiplyMysteryNumberByFive,
deleteProperty: deleteProperty,
newUser: newUser,
hasEmail: hasEmail,
hasProperty: hasProperty,
verifyPassword: verifyPassword,
updatePassword: updatePassword,
addFriend: addFriend,
setUsersToPremium: setUsersToPremium,
sumUserPostLikes: sumUserPostLikes,
addCalculateDiscountPriceMethod: addCalculateDiscountPriceMethod
};
makeCat: makeCat,
addProperty: addProperty,
invokeMethod: invokeMethod,
multiplyMysteryNumberByFive: multiplyMysteryNumberByFive,
deleteProperty: deleteProperty,
newUser: newUser,
hasEmail: hasEmail,
hasProperty: hasProperty,
verifyPassword: verifyPassword,
updatePassword: updatePassword,
addFriend: addFriend,
setUsersToPremium: setUsersToPremium,
sumUserPostLikes: sumUserPostLikes,
addCalculateDiscountPriceMethod: addCalculateDiscountPriceMethod
};