Created
June 13, 2012 07:44
-
-
Save hodbby/2922600 to your computer and use it in GitHub Desktop.
Address book
This file contains hidden or 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
<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