Tell us what’s happening:
This lessons doesn’t make much sense to me. We are asked to use the instance of instead of candidate.constructor === Dog in the tasks section in the console. But when I hit submit it says I still need to use the constructor? Isn’t the constructor candidate?
Wouldn’t candidate instanceof Dog be true automatically then?
Your code so far
function Dog(name) {
this.name = name;
}
// Only change code below this line
function joinDogFraternity(candidate) {
if(candidate instanceof Dog){
return true;
} else {
return false;
}
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36.
You are asked to use constructor. I’ll give you a similar example:
function Airplane(brand){
this.brand = brand
}
function Dog(name){
this.name = name
}
let myDog = new Dog("Joan")
let boeing = new Airplane("boeing")
function isItAnAirplane(object){
if(object.constructor=== Airplane){
return true
}
return false
}
let checkBoeing = isItAnAirplane(boeing)
let checkDog = isItAnAirplane(myDog)
console.log(checkBoeing,checkDog)
What I’d expect
paste that into the browser’s terminal
check the constructor property manually
See the output of the console log( Should be true false)
I don’t believe much in straight answers, and because you’re an avid learner I’m giving a bit complicated reply
If you can connect the output true false with the inspection of the elements, then you’re on the safe side. Conclusion: the browser creates a constructor property on every instance of an object. But this can be overwritten.