Saturday, October 16, 2021

Understand the Constructor Property

 function Dog(name) {

  this.name = name;
}

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

console.log(joinDogFraternity(beagle))
//result
//true

No comments:

Post a Comment

JavaScript Functions as JavaScript Variables

In Javascript instead of declaring and executing a function in two different steps. for example step 1 -  function add(a,b){return a+b;} ste...