Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>May Class</title>
- <script src="jquery.js" type="text/javascript"></script>
- </head>
- <body>
- <h1>It's alive!</h1>
- <script>
- contactList = [];
- build = function(first, last, email) {
- var contact = { first : first, last : last, email : email };
- contactList.push(contact);
- }
- find = function(last) {
- for (var i=0; i<contactList.length; i++) {
- if (contactList[i].last == last)
- return contactList[i];
- }
- }
- del = function(contact) {
- for (var i=0; i<contactList.length; i++) {
- if (contactList[i] == contact) {
- contactList.splice(i,1);
- return;
- }
- }
- }
- test = function() {
- build("Joe1", "Smith1", "j1@gmail.com");
- build("Joe2", "Smith2", "j2@gmail.com");
- build("Joe3", "Smith3", "j3@gmail.com");
- var name = prompt("enter last name");
- var contact = find(name);
- var newEmail = prompt("enter new email to replace " + contact.email);
- if (newEmail)
- contact.email = newEmail;
- console.log("email for " + contact.first + " " + contact.last
- + " is " + contact.email);
- }
- test();
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment