Is it not possible for me to give my new contact a name?


So, I finished this particular chapter but felt it would make sense if one could actually give one's new contact a name instead of creating it the way we're told to. I tried it this way but it says "undefined". Please help me out. I'd really love to see how it is done. Also, what is wrong with my code?

var bob = {
firstName: "Bob",
lastName: "Jones",
phoneNumber: "(650) 777-7777",
email: ""

var mary = {
firstName: "Mary",
lastName: "Johnson",
phoneNumber: "(650) 888-8888",
email: ""

var contacts = [bob, mary];

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

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

/*Create a search function
then call it passing "Jones"*/

var add = function (firstName, lastName, phoneNumber, email) {
contacts[contacts.length] = {
firstName: firstName,
lastName: lastName,
phoneNumber: phoneNumber,
email: email,

var taiwo = new add ("Taiwo", "Adedotun", "07064248915", "");

console.log (taiwo.lastName);


Not in the practical sense. It is much more organized with all the objects housed in a single array object. Named objects are useful in small numbers, but once we start accumulating them memory gets eaten up and efficiency goes out the window. That is the general intent of this lesson to point out.