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

2 Answers

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

Jane Anaekwe
Jane Anaekwe
2,295 Points

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.