Skip to content

Instantly share code, notes, and snippets.

Created September 30, 2015 21:43
Show Gist options
  • Save dustinmyers/2803c83779eeca11ca6d to your computer and use it in GitHub Desktop.
Save dustinmyers/2803c83779eeca11ca6d to your computer and use it in GitHub Desktop.
// Create a function called MakePerson which takes in name, birthday, ssn as its parameters and returns a new object with all of the information that you passed in.
function MakePerson(name, bday, ssn) {
var person = {}; = name;
person.bday = bday;
person.ssn = ssn;
return person;
var firstPerson = MakePerson("Dustin", "3/14", 98234759384759384);
var secondPerson = MakePerson("Joe", "4/14", 982347594567);
var thirdPerson = MakePerson("Jake", "5/14", 87);
// Create a function called MakeCard which takes in all the data it needs to make a Credit Card object and returns that object so that whenever you invoke MakeCard, you get a brand new credit card.
function MakeCard(cardNumber, exp) {
var card = {};
card.cardNumber = cardNumber;
card.exp = exp;
return card;
var firstCard = MakeCard(2345, "07/17");
var secondCard = MakeCard(23456, "08/17");
var thirdCard = MakeCard(234567, "09/17");
/* As of this point you should have a MakePerson and a MakeCard function which returns you either a person or a credit card object.
Now, create a bindCard function that takes in a person object as its first parameter and a creditcard object as its second parameter.
Have bindCard merge the two parameters together into a new object which contains all the properties from the person as well as the creditcard.
//Code Here
var bindCard = function(person, card) {
var newCard = {}; =;
newCard.bday = person.bday;
newCard.ssn = person.ssn;
newCard.cardNumber = card.cardNumber;
newCard.exp = card.exp;
return newCard;
var card1 = bindCard(firstPerson, firstCard);
var card2 = bindCard(secondPerson, secondCard);
var card3 = bindCard(thirdPerson, thirdCard);
console.log("card1: ", card1);
console.log("card2: ", card2);
console.log("card3: ", card3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment