Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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');


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

Michael Shields
Michael Shields
12,650 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.

console has an e at the end