First I hope I am posting this correctly on here. I passed this challenge. But then realized it says it’s “generally better to use the instanceof
method to check the type of an object” I then after passing looked at the answer in Get Hint. Also watched how others passed it on youtube. Nobody used the instanceof method. So I have been trying to figure out how to use instance of. Now I am super confused. Can anyone show me how it would be completed using (instanceof)
Thank you.
Gabe.
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;
}
return false;
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/object-oriented-programming/understand-the-constructor-property