How to pass the obj in isCute and sing ? I can access the function and then i am getting the reference error of undefined

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:

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.

It shouldn’t differ much from using class method - duck.sing()

Thank you so much . I Understand

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.