Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Object-Oriented JavaScript Working with Classes in JavaScript Instantiating a Pet Object

Jordonis Braswell
Jordonis Braswell
2,349 Points

I keep getting a Reference error but my code is exactly the same as the video,

My code class Pet{ constructor(animal,age,breed){ this.animal=animal; this.age=age; this.breed=breed; } }

const ernie = new Pet('dog', 1, 'pug'); const vera = new Pet ('dog', 8, 'border collie');

consol.log(ernie);

I get the following mesage:

ReferenceError: consol is not defined
at Object.<anonymous> (/home/treehouse/workspace/Pet.js:10:1)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3

2 Answers

console has an e at the end

console.log(ernie);
Michael Shields
Michael Shields
11,559 Points

Hi Jordonis, Kris' answer is correct in identifying the source of your error - the missing 'e' at the end of 'console'.

I just wanted to point out a helpful tip since the error message you are receiving is telling you what is going wrong so let's take a look...

ReferenceError: consol is not defined at Object<anonymous> /* this first part tells us WHAT type of error and WHAT is causing the error. It points out that we have something undefined in our Object */

(/home/treehouse/workspace/Pet.js:10:1) /* this part is pointing to WHERE our error is found. This path reflects the Treehouse workspace window, the Pet.js file, line 10. Line 10 in the code pertains to the console.log, and ties back to the 'consol' undefined ReferenceError you were receiving. */

TLDR; if you are receiving an ErrorMessage and having a hard time pinpointing what is wrong, dig through the ErrorMessage response and use that info to quickly identifying errors in your code. Sometimes commas, periods, and one misspelled letter can be hard to spot just by glancing over your code.