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
Jonathan Grieve
91,254 PointsPossible error on Constructor Function stage.
Hi all
Really enjoying the Object Oriented JavaScript course so far.
I've just a quick question about one of the quiz questions in the second stage.c
Given the following code.
function Animal(breed, noise) {
this.breed = breed;
this.noise = noise;
this.makeNoise = function() {
**console.log(this.noise + ", " + this.noise);**
}
}
Shouldn't the first one be this.breed?
What is the correct way to create an instance of an Animal?
Jonathan Grieve
91,254 PointsI can't promise a precise link to the question, but it should be in this quiz,
Scott Evans
4,236 PointsOk, just to clarify your question What are you referring to by "First one"
Jonathan Grieve
91,254 PointsSorry, I probably should have made myself clearer...
in the console.log there's 2 references to the noise property this.noise. My simple question is should there not be a this.breed since all the options in the quiz seem to refer to an animal breed.
I worked out the correct answer, it's just a point about the code that I'm asking about. :-)
1 Answer
Scott Evans
4,236 PointsIm pretty sure the console.log(this.noise + ", " + this.noise); is intended to be like this to simulate and animal making a repeated noise.
So for example;
this.noise = "Woof";
Would result in "Woof, Woof" in the console.
Jonathan Grieve
91,254 PointsYou know... you're probably right :)
I was just thrown by the fact that each supplied argument for each question had a string that was clearly meant for the this.breed property but I kept seeing 2 references to the noise property. I think there's scope for confusion there though. :-)
Scott Evans
4,236 PointsScott Evans
4,236 PointsCan you link the Specific Quiz please Jonathan Grieve