Extend Constructors to Receive Arguments.Help

Extend Constructors to Receive Arguments.Help
0

#1

Tell us what’s happening:

What is ggoing wrong with this code?

Your code so far


function Dog() {
  this.name = "bingo";
  this.color = "yellow";
  this.numLegs = 4;
}

let terrier = new Dog("name", "color");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/object-oriented-programming/extend-constructors-to-receive-arguments/


#2

@Klaudia if you are trying to pass the test that you have mentioned in the link then you need to follow the instructions exactly.

what you wrote was missing the two parameters they were requesting in the constructor (name & color).

function Dog() {
  this.name = "bingo";
  this.color = "yellow";
  this.numLegs = 4;
}

let terrier = new Dog("name", "color");

Your adjusted code should have (name) and (color) as parameters in the Dog constructor and when you create a new Dog object you would provide the specific information for that Dog objects (name) and (color). I hope this helps. There is my example below.

function Dog(name, color) {
  this.name = name;
  this.color = color;
  this.numLegs = 4;
}

let terrier = new Dog('spot', 'blue');

Best regards,


#3

Thank you I pass the test.