Well Bro❤🤝I have watched your whole JavaScript for Beginner playlist earlier. Through this video, I clearly understand what is Factory Function. Thanks a lot✨
function CreatePerson(name,age){ const place='chennai' return{ name:name, age:age, introudceself(){ return 'my name is ${obj.name}' }, place:place, } } const CreatePerson= CreatePerson('anbu',27) console.log(CreatePerson); //expected out put is not coming. could you help me anna
You have a syntax error. Modify this line: ('this is my name $(obj.name'); to return `this is my name ${obj.name}`; Remember it is `(tilde) and not '(single quotes)
Well Bro❤🤝I have watched your whole JavaScript for Beginner playlist earlier. Through this video, I clearly understand what is Factory Function. Thanks a lot✨
Thanks 😊👍
❤❤❤❤❤❤
anna unit testing jest ah vachu eppudi pannurathu nu video podungalae
Noted!
@@CyberDudeNetworks ❤️❤️❤️
function CreatePerson(name,age){
const place='chennai'
return{
name:name,
age:age,
introudceself(){
return 'my name is ${obj.name}'
},
place:place,
}
}
const CreatePerson= CreatePerson('anbu',27)
console.log(CreatePerson);
//expected out put is not coming. could you help me anna
1.Bro replace the ' with the ` in introduceself(), and alse replace the ${obj.name} with ${this.name}
Try this...
As said, you have to use backtick, not single quotes.
It should be
return `my name is ${obj.name}`
function CreatePerson(name){
return{
name,
greetings(){
return
('this is my name $(obj.name');
}
};
}
const CreatePerson = CreatePerson('nira');
console.log(CreatePerson)
getting this.name when i run the code
factory functions
You have a syntax error.
Modify this line: ('this is my name $(obj.name');
to return `this is my name ${obj.name}`;
Remember it is `(tilde) and not '(single quotes)