Shine Getter SOS

Hello.

I am currently stuck on this level, (Javascript).

Am I writing everything right @nick ?

Here is my code:

// To grab the most gold quickly, just go after gold coins.

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

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

I think you have a bunch of missing stuff.

  1. Add opening and closing brackets for the while-loop. {}
  2. Inside the while-loop but outside the if-statement, increment coinIndex Hint: coinIndex ++;
  3. I don’t think it is as necessary, but try adding in the if-statement if the coin exists. Hint: if (coin && coin.value == 3)
  4. You should make the below coins.length instead of (coins)
1 Like

also you forgot to increment. do coinIndex += 1 at the final line of your while loop

3 Likes

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.