JavaScript Node.js Basics Introduction to Node.js The Console

Wendy Anderson-Burton
Wendy Anderson-Burton
902 Points

error does not make sense

THIS IS THE CODE const name = "Andrew"; const details = { favouriteLanguage: "JavaScript", age: 33, children: 3 } const errorMessage = "Something bad has occurred"; console.log(name); console.dir(details); I needed to console the error message THIS IS WHAT I TYPED AFTER THE last line. console.err(errorMessage); Why is this wrong?

app.js
const name = "Andrew";
const details = { favouriteLanguage: "JavaScript", age: 33, children: 3 } 
const errorMessage = "Something bad has occurred";
console.log(name);
console.dir(details);
console.err(errorMessage);

4 Answers

Jennifer Nordell
STAFF
Jennifer Nordell
Treehouse Staff

Hi there! I received your request for assistance. When you try and run this code in the challenge you will receive a "console err is not a function". This is because err is not a valid console function. However, error is. If I change your last line to:

console.error(errorMessage);

Your code passes! Here is the MDN documentation that shows all valid functions on the Console object.

Hope this helps! :sparkles:

Try this:

console.error(errorMessage);
Adam Beer
Adam Beer
11,267 Points

Hi! Just a typo. console.err is not a function. Please change to console.error.

Wendy Anderson-Burton
Wendy Anderson-Burton
902 Points

Thank you all I will go back and try that.