Cannot read properety


#1

var add=function(firstName,lastName,email,phoneNumber){
var newContact = {
firstName: firstName,
lastName: lastName,
email: email,
phoneNumber: phoneNumber
};
contacts[contacts.length].newContact;
}
add("prabhal","subbaiah","prabhal.subbaiah@gmail.com","999-999-9999")
list();
i'm getting an error like Oops, try again. It looks like there are still only two items in the contacts array. can someone plz tell me whts wrong??


#2

@websolver81391,

Your

contacts[contacts.length].newContact;

should either be

contacts[contacts.length] = newContact;

or

contacts.push(newContact);

#3

thank you leonard ,,, your answer was really helpful and it worked..