6/6 Error, there are only two items in the contacts Array


#1

var contacts = new Array();

contacts[0] = mary;
contacts[1] = bob;

function printPerson(person) {
console.log(person.firstName + " " + person.lastName);
}

function list() {
var contactsLength = contacts.length;
for (var i = 0; i < contactsLength; i++) {
printPerson(contacts[i]);
}
}

var search = function(lastName){
var contactsLength = contacts.length;
for (var i = 0; i < contactsLength; i++) {
if (lastName = contacts[i].lastName){
printPerson(contacts[i]);
};
};
};

function add(firstName, lastName, email, phoneNumber){
this.firstName = firstname;
this.lastName = lastName;
this.email = email;
this.phoneNumber = phoneNumber;
contacts[contacts.length] = this

}

var tim = new add("Tim","Stephens", "tims@example.com","(650) 999-9999");

list();

I'd like some help please.


#2

@josinhu,

Try

function add(){
    console.log( this );
}

add();

#3

Don't mind, I already found the problem.


#4

What was your fix? I have the same error


#5

I misspelled firstname, it had to be 'firstName'