Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Interpreter can't find method inside "self" (this) [JS]


Hello, In the level “multiplayer-treasure-grove” I got this interpreter error:


Pass “self” in to the function as a parameter and it works - at least, it has worked for me before…

function foo (self) {
// stuff

foo (this);


Your solution did not work.
But moving the declaration to the top before the loop vanished the problem.

var self = this;

Even though, now another problem appeared:

The “x” mark does not tells any useful hint, only says “find the distance to a target unit”


You also need to declare the function outside of the loop…

“scope” isn’t really taught yet in the lessons in the game it seems - of course, none of the levels really require an understanding of it yet either.