Skip to content

Instantly share code, notes, and snippets.

@hodbby hodbby/gist:2922600
Created Jun 13, 2012

What would you like to do?
Address book
<head><title>Address Book</title></head>
<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: " +
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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.