Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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