Console.log is not a function (who knew!)


#1

Hello everybody,

I need help with my code, namely the "listing everybody" exercise. When I submit it I always get the error message "TypeError: console.log is not a function" and I have no idea why. The only console.log in the code is that from the previous exercise and there it worked perfectly well. I tried commenting out various sections including the console.log one but that also didn't give me any real insight into what's wrong.

Below 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(person) {
    console.log(person.firstName + " " + person.lastName);
};
function list(){
    
   for(var i=0;i<contacts.length;i++){
      printPerson(contacts[i]);
  }
}
list();

I would really appreciate if anyone could tell me what's wrong, it's driving me nuts!

Thanks a lot


#2

Try refreshing the page.


#3

Of course, the one thing I wouldn't think of.... Thank you very much, it worked!


#4

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