[SOLVED] Sarven Savior Help!

# An ARRAY is a list of items.
# This array is a list of your friends' names.
friendNames = ['Joan' 'Ronan' 'Nikita' 'Augustus' ]
# Array indices start at 0, not 1!
friendIndex = 0
# Loop over each name in the array.
# The .length property gets the length of the array.
while friendIndex < friendNames.length:
    # Use square brackets to get a name from the array.
    friendName = friendNames[friendIndex]
    # Tell your friend to go home.
    # Use + to connect two strings.
    hero.say (friendName + ', go home!')
    # Increment the index to get the next name from the array.
friendIndex += 1
# Go back and build a fence to keep the ogres out.
hero.moveXY (26, 30)
hero.buildXY ('fence', 29, 30)

I tried other people post but it didn’t help, my code is on the top.

Hello and welcome to codecombat discourse @Wincon! :partying_face: 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, which shows all essentials of this board! Thanks!

Why don’t you increase friendIndex in the while loop? Because this is what causes the infinite loop.

Andrei

2 Likes

wow, I can’t believe I missed that! Thank you for your help!

4 Likes

Congrats on solving the level! Can you check the tick mark next to the comment that helped you the most?
Lydia

1 Like