Error function describe() - object in JS

Hi coders,
I was practicing in object in JS and I want to insert into my object a function that print my properties, but the compiler give me an error that species is not defined.
This is my code:

let bird = {
  name: 'Falcon',
  species: "predatory",
  age: 2,
  address: "Mountain Rock",
  tweet: function(){
    console.log("Aaaaa --ooohh");
  describe: function(){
   console.log(name + species + age + address); // gives me an error!!

I ask also how to print my properties that add me to the console.log of commas for each property ( I was thinking about use join() but I don’t know if It’s correct).

That function is looking for variables with those names. If you want to refer to the properties, use the this keyword:

console.log( + this.species + ...);

Thanks @kevcomedia now it works ,but how do I to print my function in “clearer” way? Because now prints this:

'Falconpredatory2Mountain Rock'

You can put spaces between each: + ' ' + this.species + ' ' + this.age

or use template literals:

`${} ${this.species} ${this.age}`
1 Like