Tell us what’s happening:
**Your code so far**
let funModule=(()=>{
return{
isCuteMixin : (obj)=> {
obj.isCute = () => {
return true;
};
},
singMixin : (obj) => {
obj.sing = () => {
console.log("Singing to an awesome tune");
};
}
}
})();
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36
.
Challenge: Use an IIFE to Create a Module
Link to the challenge:
sanity
April 20, 2021, 1:20pm
2
What have you tried already?
function bird(name){
this.name = name;
}
let duck = new bird(“fun”);
funModule.singMixin(duck);
console.log(duck);
when the above code is compiled the output I get is
{ name: ‘fun’, sing: [Function] }
and I don’t get the value inside the function. I would like to know how to access the contents inside the function.
sanity
April 23, 2021, 12:55pm
5
It shouldn’t differ much from using class method - duck.sing()
Thank you so much . I Understand
system
Closed
October 23, 2021, 1:18am
7
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.