List Function: "Console.log not a function"


#1

From "6. List 'em all" on the contact list project for java
https://www.codecademy.com/courses/javascript-beginner-en-3bmfN/0/6?curriculum_id=506324b3a7dffd00020bf661#

This is my code for the list function:

var list = function (object) {
  for (var key in object) {
    console.log = (key);
  }
};

list (friends);

However, searching through these forums I've seen almost exclusively:

console.log(key);

I've tried both ways. With the " = ", I get "Looks like your function isn't printing right" with no output. With "console.log(key)", I get "Did you create a function called list?", and the output is an error message that reads:

TypeError: console.log is not a function. (In 'console.log(prop)', 'console.log' is "steve")

I've tried copy and pasting multiple solutions from the forums, as well as the final code from the full program itself shown on lesson 1; but I still can't get past this step. What do I do?

It's probably going to be something stupidly obvious, like I missed a semicolon.


#2

console.log = (key); // WRONG syntax
console.log(key); // correct syntax

I've tried your function and it's works fine. So, try to clear cache or another browser but please use correct syntax for console.log() method.


#3

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