[Solved] Speech is not showing in level Highlander


Hello, I’ve been trying to figure out how to beat the level Highlander in computer science 5. The Hints are confusing to me and I’ve tried to look on the internet for any help, but I couldn’t find anything.
The following is my code for he function, which for some reason doesn’t do anything except make my Hero’s text disappear.
If anyone can help, it would be much appreciated.

function wordInString(string, word) {
    var lenString = string.length;
    var lenWord = word.length;
    // Step through indexes (i) from 0 to (lenString - lenWord)
    for ( var i = 0; i < (lenString - lenWord); i++) {
        // For each of them step through indexes (j) of the word length
        for (var j = 0; j < lenWord; j++) {
            // If [i + j]th letter of the string is not equal [j]th letter of world, then break loop
            if ([i + j] != [j]) {
            // if this is the last letter of the word (j == lenWord - 1), then return true.
            if (j == lenWord - 1) {
                return true;
    // If loops are ended then the word is not inside the string. Return False.
    return true; // ∆ Remove this when the function is written.


Could you pls format your code using 3 backtiks like this ``` then we can help you


Sorry, i’m kind of new to this. How would i do that?


use 3 backticks or there will be an option that looks like this </>


Please learn to post your code properly. It’s really easy and only requires a very small amount of effort.

To post your code from the game, use the </> button or it won’t format properly. When you click the </> button, the following will appear:

Please paste ALL of your code inside the triple back tick marks.

``` <— Triple back tick marks.

Paste ALL of your code in here.

``` <— Triple back tick marks.

There are many people here willing and able to help. If you use the </> button correctly, then ALL of your code should look like this:

while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.say("My code is formatted properly")

If ALL of your code isn’t formatted like the code above, then you’re doing it wrong and we can’t see the structure of the code to troubleshoot whether or not that is the issue. Use the </> button and help us help you. This works when sending a private message as well.

Thank you.


I made an edit to format it


Ok thanks what is the error though


For some reason, it just makes my Hero’s text disappear. Nothing else changes.


You mean that your hero does not say anything?


Yes and no. The hero’s text bubbles have no words, but they still command the soldiers to move to the gate.


then this must be a bug in the level. your code is right as far as i can see


Well ok then. Thank you for your help.


What are you doing here?

            // If [i + j]th letter of the string is not equal [j]th letter of world, then break loop
            if ([i + j] != [j]) {

Are you comparing letters or only indexes?


But he says that the code is working but the speach bubbles are not showing


Yes, the speech is not showing, and that is all that happens.


I thought that was what the notes wanted me to type.


If [i + j]th letter of the string is not equal [j]th letter of world


So, like this?

 if (lenString[i + j] != lenWord[j]) {


The function has two parameters…

wordInString(string, word)


So remove the len from string and word then?