Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var contacts = [
- //John Doe's profile
- { 'firstName' : 'John',
- 'lastName' : 'Doe',
- 'phone' : '(512) 355-0453',
- 'email' : 'johndoe@email.com'
- } ,
- //Jane Doe's profile
- { 'firstName' : 'Jane',
- 'lastName' : 'Doe',
- 'phone' : '(312) 641-2203',
- 'email' : 'janedoe@email.com'
- } ,
- //Suzie Smith profile
- { 'firstName' : 'Suzie',
- 'lastName' : 'Smith',
- 'phone' : '(415) 604-4219',
- 'email' : 'suziesmith@email.com'
- } ,
- ];
- console.log(contacts);
- var addContact= function(newContact) {
- contacts.push(newContact);
- } ;
- console.log(contacts);
- var listContacts = function() {
- for ( var i = 0 ; i < contacts.length ; i++){
- console.log(contacts[i].firstName + ' ' + contacts[i].lastName);
- }
- };
- listContacts();
- var search = function(name) {
- for (var a = 0; a < contacts.length ; a++){
- if (contacts[a].firstName + ' ' + contacts[a].lastName === name)
- {
- console.log("Phone: " + contacts[a].phone);
- console.log("email: " + contacts[a].email);
- }
- }};
- search("John Doe");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement