complete-javascript-course icon indicating copy to clipboard operation
complete-javascript-course copied to clipboard

I cant call a method in a object

Open msundartirupur opened this issue 4 years ago • 2 comments

const jones={ firstName:'jones',

lastNmae:'school', age:40, lisence:true, profession:"doctor", isHasLisence :function(){ return this.lucky=this.lisence?'a drivers lisence':'No driving lisence';

}

};

console.log("${jones.firstName} is a ${jones.age} years old ${jones.profession} ,and he has ${jones.lucky}");

msundartirupur avatar Oct 01 '21 09:10 msundartirupur

Don't you need to use backticks for template literals? (``)

Jyc-alC avatar Oct 05 '21 08:10 Jyc-alC

const jones={ firstName:'jones',

lastNmae:'school', age:40, lisence:true, profession:"doctor", isHasLisence :function(){ return this.lucky=this.lisence?'a drivers lisence':'No driving lisence';

}

};

console.log("${jones.firstName} is a ${jones.age} years old ${jones.profession} ,and he has ${jones.lucky}");

U used placeholders in log, however these last are used in template literals which they're enclosed by the backtick ( ' ) character instead of double or single quotes.

OuaklimOthmane avatar Feb 04 '22 01:02 OuaklimOthmane