Understand the Constructor Property JS

Tell us what’s happening:

…Am stacked for hours kindly go through let me what is missing…

Your code so far


function Dog(name) {
this.name = name;
function joinDogFraternity(candidate) {
if (candidate.constructor === Dog) {
  return true;
} else {
  return false;
}
}
}
// Only change code below this line
function joinDogFraternity(candidate) {

}

Your browser information:

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

Challenge: Understand the Constructor Property

Link to the challenge:

HI @matey1979!

You wrote all of your code above the line not below.

I would suggest indenting your code.

function joinDogFraternity(candidate) {
  if (candidate.constructor === Dog) {
    return true;
  } else {
    return false;
  }
}

The if else statement would be a good case for ternary operator. (optional)

function joinDogFraternity(candidate) {
return  candidate.constructor === Dog ? true : false; 
}

You could get even crazier and rewrite the function using es6 arrow notation. (optional)

const joinDogFraternity = (candidate) =>
  candidate.constructor === Dog ? true : false;

Yeah I later saw it thanks