# Always get line 8:type error: statement execution limit reached

**URL:** <https://discourse.codecombat.com/t/always-get-line-8-type-error-statement-execution-limit-reached/28294>\
**Category:** Level Help\
**Created:** [April 6, 2021, 2:53am UTC](https://discourse.codecombat.com/t/always-get-line-8-type-error-statement-execution-limit-reached/28294 "2021-04-06T02:53:47Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![somenewguy](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@somenewguy](https://discourse.codecombat.com/u/somenewguy)\
**Post date:** [April 6, 2021, 2:53am UTC](https://discourse.codecombat.com/t/always-get-line-8-type-error-statement-execution-limit-reached/28294/1 "2021-04-06T02:53:47Z")

</div>

pls help,I couldn’t figure out.  
always get line 8:type error: statement execution limit reached  
what’s the issue here?

```python

while(true) {
    var coins = hero.findItems();
    var coinIndex = 0;

// Wrap this into a loop that iterates over all coins.
  while(coinIndex < coins.length) { 
        var coin = coins[coinIndex];
        // Gold coins are worth 3.
        if (coin.value == 3) {
            // Only pick up gold coins.
            hero.moveXY(coins.pos.x, coins.pos.y);
            coinIndex += 1;
        }
    }
}
```

---

<div class="post-metadata">

**Author:** ![enPointe77](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/enpointe77/32/43632_2.png) [@enPointe77](https://discourse.codecombat.com/u/enPointe77)\
**Post date:** [April 6, 2021, 4:11am UTC](https://discourse.codecombat.com/t/always-get-line-8-type-error-statement-execution-limit-reached/28294/2 "2021-04-06T04:11:26Z")

</div>

Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review [this topic](https://discourse.codecombat.com/t/welcome-to-codecombat-discourse-forums/15601), which shows all essentials of this board! Thanks!

---

<div class="post-metadata">

**Author:** ![enPointe77](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/enpointe77/32/43632_2.png) [@enPointe77](https://discourse.codecombat.com/u/enPointe77)\
**Post date:** [April 6, 2021, 4:17am UTC](https://discourse.codecombat.com/t/always-get-line-8-type-error-statement-execution-limit-reached/28294/3 "2021-04-06T04:17:15Z")

</div>

Can you use use this button: \</\> and put your code down? It helps everyone help you.

---

<div class="post-metadata">

**Author:** ![somenewguy](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@somenewguy](https://discourse.codecombat.com/u/somenewguy)\
**Post date:** [April 6, 2021, 5:06am UTC](https://discourse.codecombat.com/t/always-get-line-8-type-error-statement-execution-limit-reached/28294/5 "2021-04-06T05:06:23Z")

</div>

ok i did that defswf

---

<div class="post-metadata">

**Author:** ![CocoCharlie](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/cococharlie/32/19081_2.png) [@CocoCharlie](https://discourse.codecombat.com/u/CocoCharlie)\
**Post date:** [April 6, 2021, 3:56pm UTC](https://discourse.codecombat.com/t/always-get-line-8-type-error-statement-execution-limit-reached/28294/6 "2021-04-06T15:56:43Z")

</div>

What level is this?  
20

---

<div class="post-metadata">

**Author:** ![somenewguy](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@somenewguy](https://discourse.codecombat.com/u/somenewguy)\
**Post date:** [April 6, 2021, 7:36pm UTC](https://discourse.codecombat.com/t/always-get-line-8-type-error-statement-execution-limit-reached/28294/7 "2021-04-06T19:36:52Z")

</div>

its called shine getter on the desert map

---

<div class="post-metadata">

**Author:** ![Hydrobolic](https://avatars.discourse-cdn.com/v4/letter/h/e47c2d/32.png) [@Hydrobolic](https://discourse.codecombat.com/u/Hydrobolic)\
**Post date:** [April 6, 2021, 8:02pm UTC](https://discourse.codecombat.com/t/always-get-line-8-type-error-statement-execution-limit-reached/28294/8 "2021-04-06T20:02:54Z")

</div>

Statement execution limit usually means something is stuck in an infinite loop. In this case, it’s your loop going across all coins.

Think carefully about what happens if it’s currently inspecting, say, a silver coin (`coin.value == 2`). Since the if statement isn’t run, `coinIndex` is never incremented, and the loop will run again inspecting the same coin. Repeat forever.

To solve this you’ll want to move `coinIndex += 1` out of the if statement. Regardless of whether the coin is a gold coin or not, you don’t want to handle it again, so increment to the next one.

---

<div class="post-metadata">

**Author:** ![somenewguy](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@somenewguy](https://discourse.codecombat.com/u/somenewguy)\
**Post date:** [April 6, 2021, 8:03pm UTC](https://discourse.codecombat.com/t/always-get-line-8-type-error-statement-execution-limit-reached/28294/9 "2021-04-06T20:03:37Z")

</div>

ok ill try that thanks

---

<div class="post-metadata">

**Author:** ![somenewguy](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@somenewguy](https://discourse.codecombat.com/u/somenewguy)\
**Post date:** [April 6, 2021, 8:05pm UTC](https://discourse.codecombat.com/t/always-get-line-8-type-error-statement-execution-limit-reached/28294/10 "2021-04-06T20:05:50Z")

</div>

it worked thank you 😃

---

<div class="post-metadata">

**Author:** ![Anonym](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/anonym/32/47546_2.png) [@Anonym](https://discourse.codecombat.com/u/Anonym)\
**Post date:** [April 7, 2021, 5:49pm UTC](https://discourse.codecombat.com/t/always-get-line-8-type-error-statement-execution-limit-reached/28294/11 "2021-04-07T17:49:29Z")

</div>

Please, select the post which helped you to solve the level.
