Why does this Constructor test return false?

Tell us what’s happening:
I am working on the challenge “Learn OOP: Understand the Constructor Property”, and my code passes, but I am confused about the result of “false” for the


line. Can someone explain why this is returning “false” and not “true”?


Your code so far

function Dog(name) {
 this.name = name;

// Add your code below this line
function joinDogFraternity(candidate) {
if (candidate.constructor === Dog) {
   return true;
 } else {
   return false;
let ourDog = new Dog("tess");

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:72.0) Gecko/20100101 Firefox/72.0.

Challenge: Understand the Constructor Property

Link to the challenge:

You’re getting false because you entered a string instead of the variable itself.

change the code to console.log(joinDogFraternity(ourDog))
and you will get true.

The function joinDogFraternity() is checking whatever variable you enter into it. Remember strings are primitive values, so the string ‘tess’ only contains the information ‘tess.’ The information you’re looking for is stored in the variable ourDog, which also contains the string ‘tess’, and the information about the constructor.

1 Like