Skip to content

Instantly share code, notes, and snippets.

@hodbby
Created June 13, 2012 07:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hodbby/2922600 to your computer and use it in GitHub Desktop.
Save hodbby/2922600 to your computer and use it in GitHub Desktop.
Address book
<html>
<head><title>Address Book</title></head>
<body>
<script type="text/javascript">
var contacts = [];
function printPerson (person) {
document.write("First Name is: " + person.firstName)
document.write("</br>Last Name is: " + person.lastName)
document.write("</br>Email is: " + person.email)
document.write("</br>Telephone is: " + person.phoneNumber);
}
function list () {
var i;
for (i=0;i<contacts.length;i++) printPerson(contacts[i]);
}
function add (firstName,lastName,email,telephone) {
var newContact = {firstName:firstName, lastName:lastName, phoneNumber:telephone, email: email};
return newContact;
}
var fN = prompt("first name");
var lN = prompt("last name");
var pN = prompt("telephone");
var em = prompt("email");
contacts[contacts.length] = add (fN,lN,pN,em);
list();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment