Displaying People: My Browser keeps freezing when I click submit code


#1

Whenever I hit "Save/Submit Code," my browser keeps freezing. I don't know if this is something in my code or a bug with CodeCademy, but this is my code:

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(bob) {
console.log(bob.firstName + " " + bob.lastName);
printPerson(contacts[0]);
}

Has anyone else encountered this problem?


#2

Back to instructions..
problem1

Define a function called printPerson that takes a parameter called person

and your code..

function printPerson(bob)

problem2
also your calling the function by itself by putting the call statement inside of it.(reason of freezing)
function printPerson(bob) {
console.log(bob.firstName + " " + bob.lastName);
printPerson(contacts[0]);
}


#3

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

The instructions over complicate the question. You don't need a variable called contactsLength because that's just the same thing as contacts.length. Also, don't call printPerson while it's inside of the function printPerson. That's probably why it freezes.


#4

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