Object Oriented Programming: Understand the Constructor Property

Tell us what’s happening:
I passed the requirements but the answer is not accepted. I tried with an if/else and with the method below. Both return true/false as required. Somehow the challenge is still not passed. What am I missing here?

Your code so far


// Object Oriented Programming: Understand the Constructor Property

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

let beagle = new Dog();

// Add your code below this line
function joinDogFraternity(candidate) {
return candidate.constructor === Dog;
}

// NOTE: constructor property can be overwritten; to check, better to use
// instanceof method.

console.log(joinDogFraternity(beagle))

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0.

Challenge: Understand the Constructor Property

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/object-oriented-programming/understand-the-constructor-property

Seems like something about that durn beagle really murphed the tests. Reset all code, clear it back to the default, and just put in the return line - passes fine.

1 Like

Actually, it was the fact that the commented code “instanceof” was being caught by the test and the test was validating that only the constructor property was being checked and that instanceof was not being used in the solution.

I am currently working on ignoring code comments in all applicable JavaScript challenge tests. Only a handful currently ignore commented code.

2 Likes

it worked, thanks guys! Glad the beagle was not to blame…this time