Binary Deployment Level (Adventurer)

The system is complaining about something that does not make sense.
It says case problem but it is lowercase typed just as suggested by the autocomplete.

Do you have the correct Boss Star equipped with the archer type?

The same problemas haappens with soldier type.
I’ve just put archer first for testing porpuses.

@marciofao Use this.summoning = function () {...} (because that’s how JavaScripts this works.)
(Or you can .bind(this) on the function or .call(this) later…)


The level itself is pretty cool though! The only problem is that I can’t do something like this:

function toBase (base, d) { /* ... */ }
var toBinary = toBase.bind(null, 2)
var toTrinary = toBase.bind(null, 3)
// or even better, `_.partial(toBase, base)`

But that’s okay. Also, I don’t think there is a need for a leaderboard for fastest time…

Hey, what’s up @marciofao.

As already mentioned, the problem is that you are losing the this reference.
When you call a function – e.g. foo() – without using property access notation, call, apply, bind nor arrow functions, this will reference the global object (or undefined in strict mode).

You can run this example in your browser console:

var obj = {
  method: function() {
    console.log(this);
  }
};

// property access notation:
obj.method(); // this inside method == obj
obj['method'](); // this inside method == obj

// save a reference to the function which `obj.method` resolves to:
var func = obj.method;
// now do a bare function call:
func(); // this == window

// call/apply/bind:
func.call(obj); // this == obj
func.apply(obj); // this == obj
func.bind(obj)(); // this == obj

// ES2015 arrow function (requires recent version of Firefox, Edge or Chrome >= 45¹):
({
  method() {
    // `this` inside the arrow function is the same as outer scope's
    var arrowFunc = () => console.log(this);
    arrowFunc();
  }
}).method(); // this == the object whose `method` is a property of

I’m checking up the slides for the minicourses that I gave in the past SASPI events (if I recall correctly, you attended both of them, right?) and unfortunately I can’t seem to find resources about this. I believe I deliberately decided to skip over this because our time was very constrained and this is a rather complex beast. Well, this is really something that I should address in the next edition! :wink:


¹ Chrome 45 is currently in beta, you’d need to use the Beta, Dev or Canary Chrome channel or your own build of Chromium if you want to run the ES2015 example in Chrome. It is easier to just run that example in Firefox. :smile: