Use an IIFE to Create a Module

Tell us what’s happening:

Hello, the run tests is not doing anything. Is the code wrong or an issue for Github

Your code so far


let funModule = (function(){
  return {
    singMixin = function(obj) {
      obj.sing = function() {
        console.log("Singing to an awesome tune");
      };
    },
    isCuteMixin = function(obj) {
      obj.isCute = function() {
        return true;
      };
    }
  }
})();

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/object-oriented-programming/use-an-iife-to-create-a-module/

The problem is that you are not using the correct object syntax. When you are inside of an object, you must set keys and values.

Objects look like this:

{
  nameOfFunction:  function() {}
}

Yours looks like this:

{
  let nameOfFunction = function () {}
}

Rather than using an equality operator and variable declarations, you need to set properties on the object with the syntax key: value, or nameOfMethod: function() { ..... }

1 Like

Thank you very much. Objects sometimes still confuse me a little! :disappointed_relieved:

This is my solution. It ran correctly try this. But there is no much difference between my code an yours.
var funModule = (function () {
return {
isCuteMixin: function (obj) {
obj.isCute = function() {
return true
}
},
singMixin: function(obj) {
obj.sing = function() {
console.log(“Singing to an awesome tune”)
}
}
}
}) ();