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

**URL:** <https://discourse.codecombat.com/t/interpreter-cant-find-method-inside-self-this-js/2007>\
**Category:** Bugs\
**Created:** [December 20, 2014, 12:22am UTC](https://discourse.codecombat.com/t/interpreter-cant-find-method-inside-self-this-js/2007 "2014-12-20T00:22:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![marciofao](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/marciofao/32/1775_2.png) [@marciofao](https://discourse.codecombat.com/u/marciofao)\
**Post date:** [December 20, 2014, 12:22am UTC](https://discourse.codecombat.com/t/interpreter-cant-find-method-inside-self-this-js/2007/1 "2014-12-20T00:22:23Z")

</div>

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

[![](https://i.imgur.com/ci3IcAX.png) ](https://i.imgur.com/ci3IcAX.png)

---

<div class="post-metadata">

**Author:** ![mikelburk](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@mikelburk](https://discourse.codecombat.com/u/mikelburk)\
**Post date:** [December 20, 2014, 3:09am UTC](https://discourse.codecombat.com/t/interpreter-cant-find-method-inside-self-this-js/2007/2 "2014-12-20T03:09:48Z")

</div>

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);

---

<div class="post-metadata">

**Author:** ![marciofao](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/marciofao/32/1775_2.png) [@marciofao](https://discourse.codecombat.com/u/marciofao)\
**Post date:** [December 20, 2014, 4:34am UTC](https://discourse.codecombat.com/t/interpreter-cant-find-method-inside-self-this-js/2007/3 "2014-12-20T04:34:42Z")

</div>

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

```
var self = this;
loop{
...
}

```

Even though, now another problem appeared:

[![](https://i.imgur.com/3cqP9fY.png) ](https://i.imgur.com/3cqP9fY.png)

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

---

<div class="post-metadata">

**Author:** ![mikelburk](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@mikelburk](https://discourse.codecombat.com/u/mikelburk)\
**Post date:** [December 20, 2014, 7:33pm UTC](https://discourse.codecombat.com/t/interpreter-cant-find-method-inside-self-this-js/2007/4 "2014-12-20T19:33:52Z")

</div>

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.
