Created
December 22, 2016 00:20
-
-
Save Philocoder93/cbbf2fdd91167e9afe3477b07adfca52 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 john = { | |
| 'firstName':'john', | |
| 'lastName':'doe', | |
| 'phone':'(512) 355-0453', | |
| 'email':'johndoe@email' | |
| }; | |
| var jane = { | |
| 'firstName':'jane', | |
| 'lastName':'doe', | |
| 'phone':'(312) 641-2203', | |
| 'email':'janedoe@email.com' | |
| }; | |
| var suzie = { | |
| 'firstName':'suzie', | |
| 'lastName':'smith', | |
| 'phone':'(415) 604-4219', | |
| 'email':'suziesmith@email.com' | |
| }; | |
| var contacts = []; | |
| contacts[0] = john; | |
| contacts[1] = jane; | |
| contacts[2] = suzie; | |
| var addContact = function(newContact) { | |
| contacts.push(newContact); | |
| return(contacts); | |
| }; | |
| var listContacts = function() { | |
| for (i=0;i<contacts.length;i++) { | |
| console.log(contacts[i]['firstName']); | |
| console.log(contacts[i]['lastName']); | |
| } | |
| }; | |
| var search = function(name) { | |
| for (i=0;i<contacts.length;i++) { | |
| if (contacts[i]['firstName'] = name) { | |
| return contacts[i]; | |
| } | |
| else if (contacts[i]['lastName'] = name) { | |
| return contacts[i]; | |
| } | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment