-
-
Save ashleyvernon/0a2f8b6875ed61ba432854270cabf27d to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/zebofe
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
var contacts = [ | |
{ | |
'firstName' : 'John', | |
'lastName' : 'Doe', | |
'phone' : '(512) 355-0453', | |
'email' : 'johndoe@email.com' | |
}, | |
{ | |
'firstName' : 'Jane', | |
'lastName' : 'Doe', | |
'phone' : '(512) 355-0453', | |
'email' : 'janedoe@email.com' | |
}, | |
{ | |
'firstName' : 'Suzie', | |
'lastName' : 'Smith', | |
'phone' : '(512) 355-0453', | |
'email' : 'suziesmith@email.com' | |
} | |
]; | |
var newbie = { | |
'firstName' : 'John', | |
'lastName' : 'Doe', | |
'phone' : '(512) 355-0453', | |
'email' : 'johndoe@email.com' | |
}; | |
var listContacts = function() { | |
for (var i = 0; i < contacts.length; i++) { | |
console.log(contacts[i]['firstName'] + ' ' + contacts[i]['lastName']); | |
} | |
}; | |
var search = function(name) { | |
for (var i = 0; i < contacts.length; i++) { | |
if (contacts[i]['firstName'] === name || contacts[i]['lastName'] === name) { | |
return contacts[i]; | |
} | |
} | |
}; | |
var addContact = function(newContact) { | |
contacts.push(newContact); | |
return contacts; | |
}; | |
addContact(newbie); | |
listContacts(); | |
search('Suzie'); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var contacts = [ | |
{ | |
'firstName' : 'John', | |
'lastName' : 'Doe', | |
'phone' : '(512) 355-0453', | |
'email' : 'johndoe@email.com' | |
}, | |
{ | |
'firstName' : 'Jane', | |
'lastName' : 'Doe', | |
'phone' : '(512) 355-0453', | |
'email' : 'janedoe@email.com' | |
}, | |
{ | |
'firstName' : 'Suzie', | |
'lastName' : 'Smith', | |
'phone' : '(512) 355-0453', | |
'email' : 'suziesmith@email.com' | |
} | |
]; | |
var newbie = { | |
'firstName' : 'John', | |
'lastName' : 'Doe', | |
'phone' : '(512) 355-0453', | |
'email' : 'johndoe@email.com' | |
}; | |
var listContacts = function() { | |
for (var i = 0; i < contacts.length; i++) { | |
console.log(contacts[i]['firstName'] + ' ' + contacts[i]['lastName']); | |
} | |
}; | |
var search = function(name) { | |
for (var i = 0; i < contacts.length; i++) { | |
if (contacts[i]['firstName'] === name || contacts[i]['lastName'] === name) { | |
return contacts[i]; | |
} | |
} | |
}; | |
var addContact = function(newContact) { | |
contacts.push(newContact); | |
return contacts; | |
}; | |
addContact(newbie); | |
listContacts(); | |
search('Suzie');</script></body> | |
</html> |
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 contacts = [ | |
{ | |
'firstName' : 'John', | |
'lastName' : 'Doe', | |
'phone' : '(512) 355-0453', | |
'email' : 'johndoe@email.com' | |
}, | |
{ | |
'firstName' : 'Jane', | |
'lastName' : 'Doe', | |
'phone' : '(512) 355-0453', | |
'email' : 'janedoe@email.com' | |
}, | |
{ | |
'firstName' : 'Suzie', | |
'lastName' : 'Smith', | |
'phone' : '(512) 355-0453', | |
'email' : 'suziesmith@email.com' | |
} | |
]; | |
var newbie = { | |
'firstName' : 'John', | |
'lastName' : 'Doe', | |
'phone' : '(512) 355-0453', | |
'email' : 'johndoe@email.com' | |
}; | |
var listContacts = function() { | |
for (var i = 0; i < contacts.length; i++) { | |
console.log(contacts[i]['firstName'] + ' ' + contacts[i]['lastName']); | |
} | |
}; | |
var search = function(name) { | |
for (var i = 0; i < contacts.length; i++) { | |
if (contacts[i]['firstName'] === name || contacts[i]['lastName'] === name) { | |
return contacts[i]; | |
} | |
} | |
}; | |
var addContact = function(newContact) { | |
contacts.push(newContact); | |
return contacts; | |
}; | |
addContact(newbie); | |
listContacts(); | |
search('Suzie'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment