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 trialAaron Thomas
Full Stack JavaScript Techdegree Student 13,189 Pointsnothing happens when I run "node Pet.js"
here is my code....
class Pet { constructor(animal, age, breed) { this.animal = animal; this.age = age; this.breed = breed; } }
const ernie = new Pet('dog', 1 , 'pug');
and this is the response...
treehouse:~/workspace$ node Pet.js
treehouse:~/workspace$
3 Answers
Agop Karoghlanian
Courses Plus Student 9,058 PointsNothing happened because you didn't log the output to the console, so node didn't show you the results. You need to console.log(ernie)
at the end of your code. Happy coding!
Steven Parker
231,275 PointsThis code doesn't try to output anything (as might be done with a console.log
statement), so everything appears to be working. When you give the command, node executes the code, and it runs without errors, and when it is complete node exits and you get another system prompt.
Julieta Dalla Pozza
4,337 PointsMe i have put the output in console.log and nothing seem to be happen
const ernie = { animal: 'dog', age: '1', breed: 'pug', bark: function(){ console.log('Woof!'); } }
console.log(ernie.age); console.log(ernie.breed);
treehouse:~/workspace$ node pets.js
treehouse:~/workspace$ pets.js
bash: pets.js: command not found
treehouse:~/workspace$
Steven Parker
231,275 PointsDid you remember to save your changes in the editor before giving the command to run it?