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

Hanna Zeif
Hanna Zeif
11,309 Points

Nothing happens

My code looks identical to what's on the screen but it's not doing anything. When I type "node Pet.js into the console it just gives me another line in the console, no output. Here's 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');

console.log(ernie);

4 Answers

Make sure to save the Pet.js document (command S or control S). It might just be you haven't saved the recent changes you just added then nothing happens because nothing has been saved yet.

Marcos Velasco
Marcos Velasco
3,298 Points

I would recommend installing node.js and using Visual Studio code since you would have to use it in the future anyways.

I copied your code and pasted it into the workspace, it looks like it is working fine: link to image

I was having this same problem because I wasn't paying attention when she added the console.log(ernie) portion and the view later is scrolled up. :)