Use a Mixin to Add Common Behavior Between Unrelated Objects

Use a Mixin to Add Common Behavior Between Unrelated Objects
0.0 0


Tell us what’s happening:

Your code so far

let bird = {
  name: "Donald",
  numLegs: 2

let boat = {
  name: "Warrior",
  type: "race-boat"

// Add your code below this line

let glideMixin = function(glide) {
  glideMixin.bird = function(glide) {

Your browser information:

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

Link to the challenge:


Mh, the function is a bit messy; the parameter of the first function indicate the ‘object’ you want to give the ability to glide: I suggest you to give it a more general name to not being confused.
Inside the first function you should define the method ( in the challenge is ‘glide’, i’m using something else for example purpose ) applied to the object you passed in through the first function: something like

let firstFunc = function(stuff) {
  stuff.turn = function () {
         "I am turning, whoo!!"

After that, you’re missing the part where you assign different objects the ability to glide, something like:


Hope it helps!


You should use like this

let glideMixin = function(boat) {
 boat.glide = function() {