5. Adding to an existing switch (console.log is not a function?)


#1

var color = prompt("What's your favorite primary color?","Type your favorite color here");

switch(color) {
  case 'red':
    console.log("Red's a good color!");
    break;
  case 'blue':
    console.log("That's my favorite color, too!");
    break;
  //Add your case here!
   case 'yellow':
    console.log("thats cool");
    break;
  default:
    console.log("I don't think that's a primary color!");
}

it says: TypeError: console.log is not a function.

what am I doing wrong?


#2

TypeError: console.log is not a function.

This often happens when console.log = (value) is used instead of console.log(value). In this case console.log gets overwritten with the value instead of displaying it. The solution here is to just refresh the page to reload the javaScript and thereby resetting console.log to its original value.


#3

You also need to add a break underneath the default.


#4

Default is the last case so you'll stop there anyway :wink: