Why is firstname not defined


#1

var bob = {
firstName: "Bob",
lastName: "Jones",
phoneNumber: "(650) 777-7777",
email: "bob.jones@example.com"
};

var mary = {
firstName: "Mary",
lastName: "Johnson",
phoneNumber: "(650) 888-8888",
email: "mary.johnson@example.com"
};

var contacts = [bob, mary];

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 addperson = confirm("do you want to add a person");
if(addperson) {
var firstname = prompt("What is his name")
}

/*Create a search function
then call it passing "Jones"*/
function add(object,firstName,lastName,email,phoneNumber) {

firstname.firstName = firstName,
Anonymous.lastName = lastName,
 Anonymous.email = email,
Anonymous.phoneNumber = phoneNumber

}
var Hozaifa = {

};

contacts[contacts.length] = Anonymous;
//var Anonymous = new
add (Anonymous,firstName,"Anonymous2","Anonymous3","Anonymous4")

var search = function(lastName)
{
var contactsLength = contacts.length;

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

}
search("Anonymous")
list();


#2

Well if you turn that question around, why do you think it is defined?

You're using it. But where do you define it? (You don't, or we wouldn't be here)