Last active
August 7, 2016 06:23
-
-
Save anuoluwapo/5848ed628f8bd827ec5da4aec3fc6d4b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bob = { | |
firstName: "Bob", lastName: "Jones", | |
phoneNumber: "(650) 777-7777", | |
email: "bob.jones@example.com" | |
}; | |
var mary = { | |
firstName: "Mary", | |
lastName: "Johnson", | |
phoneNumber: "(650) 888-8888", | |
email: "mary.johnson@example.com" | |
}; | |
var contacts = [bob, mary]; | |
var list = function(){ | |
for (var i = 0; i < contacts.length; i++) { | |
console.log(contacts[i]); | |
} | |
} | |
function search(lastName){ | |
for(var i = 0; i < contacts.length; i++){ | |
if(contacts[i].lastName === lastName){ | |
console.log("Bob Jones"); | |
} | |
} | |
} | |
function add(firstname, lastname, phonenumber, eMail){ | |
newEntry = { | |
firstName: firstname, | |
lastName: lastname, | |
phoneNumber: phonenumber, | |
email: eMail | |
}; | |
contacts.push(newEntry); | |
} | |
console.log(add("Anu", "Oluwapo", "12355555", "alaja@eko.cc")); | |
console.log(list()); | |
//give this output | |
>Object { firstName: "Bob", lastName: "Jones", phoneNumber: "(650) 777-7777", email: "bob.jones@example.com" } | |
>Object { firstName: "Mary", lastName: "Johnson", phoneNumber: "(650) 888-8888", email: "mary.johnson@example.com" } | |
>undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment