[SOLVED] I have a "Convenient Enemy" ;)

 var word = words.length - 1 ;
        // Summon the required unit type.

I can’t understand how to summon the unit correctly, because if it is


it’s like saying


and it should be


and if it is


the computer thinks that “word” is a buildType

please help!
—foxfire :fox_face:

word stands for "soldier" quotes and all.

Look again at the instructions:

"words" is an array of words from the "message"

At the moment you’ve written:

var word = words.length - 1 ;

If your variable words is (for example) a sentence made up of 5 words, then this definition means that word = 5 - 1 = 4. In your code at the moment, you’re then trying to summon ‘4’. Is that what you want?

To answer your question, once you define word right then you want hero.summon(word) not hero.summon(“word”), as you want to use the variable you’ve defined.


var word = words.length-(words.length-1)

is this the right variable? because I tried it and it doesn’t work … :worried:

Not quite right, but you’re getting closer.

If you wanted the fifth element of the array words, what would you write?



but in this level, I don’t know how much words are in the message

Great! And yes you’re exactly right that you don’t know the number of words in the message. So instead of ‘4’ put in ‘words.length-1’, and then the code will work every time.

1 Like

thank you soooooo much!
that solved the problem!

Well done :grin:.


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