This is valid code, but the console says there is an error

Tell us what’s happening:
this is valid code, but the console says there is an error.
TypeError: this is undefined

  **Your code so far**
function Dog() {
this.name = "jimmybabimmy";
this.color = "yellow";
this.numLegs = null;
}
console.log(Dog())
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Firefox/102.0

Challenge: Define a Constructor Function

Link to the challenge:

Delete this line. The next lesson will show you how to correctly call a constructor.

ok, thank you. i thought i had to initalize it.

1 Like