I am unable to run my code. HOW TO ADD A NEW FRIEND..need help!


<II spend good time searching the error but … I stock… please need some help soon!!!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
We Made a Friend!

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
Oops, try again. It looks like there are still only two items in the contacts array.
ReferenceError: ‘firstName’ is undefined

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"

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

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

/*Create a search function
then call it passing "Jones"*/
var search = function(lastName){
    var contactsLength = contacts.length;
    for (var i = 0; i < contactsLength; i++){
        if(contacts[i].lastName === lastName) {

function add(firtsName, lastName, email, phoneNumber){
    contacts[contacts.length] = {
        firstName: firstName,
        lastName: lastName,
        email: email,
        phoneNumber: phoneNumber
add("1", "2", "3", "4");





function add(firtsName, lastName, email, phoneNumber){

you misspelled firstName, so then `firstName is undefined later on


I did correct the TYPO but still not running . it is showing this error:
Oops, try again. Make sure the contacts array still exists. Your code threw the following error when checking contacts: ReferenceError: ‘contacts’ is undefined


where did you contacts array go? You added earlier, it should still be present. Revisit the exercise where you add the contacts array if you have to


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.