View difference between Paste ID: Kb8xTvUT and bNkmhWWR
SHOW: | | - or go back to the newest paste.
1
var bob = {
2
    firstName: "Bob",
3
    lastName: "Jones",
4
    phoneNumber: "(650) 777-7777",
5
    email: "[email protected]"
6
};
7
8
var mary = {
9
    firstName: "Mary",
10
    lastName: "Johnson",
11
    phoneNumber: "(650) 888-8888",
12
    email: "[email protected]"
13
};
14
15
var contacts = [bob, mary];
16
17
function printPerson(person) {
18
    console.log(person.firstName + " " + person.lastName);
19
}
20
21
function list() {
22
	var contactsLength = contacts.length;
23
	for (var i = 0; i < contactsLength; i++) {
24
		printPerson(contacts[i]);
25
	}
26
}
27
28
/*Create a search function
29
then call it passing "Jones"*/
30
31
32
33
var add = function(firstName,lastName,email,phoneNumber) {
34-
      firstName= firstName;
34+
      contacts[contacts.length] = {
35-
      lastName= lastName;
35+
	firstName: firstName,
36-
      email=  email;
36+
      	lastName: lastName,
37-
      phoneNumber= phoneNumber;
37+
      	email:  email,
38-
      contacts[contacts.length] = {firstName:lastName};
38+
     	phoneNumber: phoneNumber	
39
      };
40
};
41
42
add("Sam","Roar","[email protected]","(650) 999-9999");
43
list();