pls can anyone help check what’s wrong with this code on the exercise: Object Oriented Programming: Use an IIFE to Create a Module.
It says music not defined and didn’t pass it. i need help for i thought i followed the lesson correctly
To initialize? i was closely following the lesson and trying to understand the topic. but in the example there wasn’t anything like initializing. pls how do i go about it?
I seem to be confused! pls.
So, as @snigo has said, if you haven’t defined music, delete those four lines.
The lesson isn’t asking you to use the mixin module you’re creating, simply to create it. But, if you wanted to try using your mixin, then you’re doing it exactly right - call that mixin name, and pass in the object you want to attach the mixin to:
Before that mixin call, the music class would likely not have had that method attached. The whole point of the mixin module is to allow you to attach common functionality to other objects, by keeping them in a common “mixin” module.
The issue here is, you haven’t created an object called music. Try this before those last four lines:
// let's create a music object
const music = {
name: "Music music music!",
play: function(){
console.log("I am playing, lalalala!")
}
}
// Now, we can use the funModule mixin functions to attach functionality
// to the music object! Yaaay!
That simply creates an object, and we can pass that object into our mixins to add some functionality.