The second loop problem. I'm very muddled and no one seems to share my problem


#1

var text = "Hey, I was wondering if we had art class today, Artreyu: do we? Because i've brought my Artreyu stuff for the class. Artreyu. Art, blahahahaha blahahaha, Artreyu.";
var myName = "Artreyu";
var hits = [];

for ( var i = 0; i < text.length; i ++) {
    if( text[i] === 'A') {
        for( var j = i; j < (myName.length+i) ; j ++) {
            hits.push(text[j]);
            
        }
    }

    
};
if(hits.length === 0 ) {
    console.log("Your name wasn't found")
}
else {
console.log( hits );
}

I get Your name wasn't found.


#2

@artreyu
On line eleven, your curly brace } doesn't need a semicolon. You console.log("Your name wasn't found") should have a semicolon at the end of it. Hope this helped you.


#3

Your correct about the semicolons still I get 5 outputs when I run the code 4 for "Atreyu" and 1 for "Art". Maybe try to refresh the page and give it another try as it should really work. Maybe stuff got stuck in the memory from a former try and would be resolved by refreshing the page.


#4

If you erase the last sentence in your text it works. I think it doesn't like something with the names in the last sentence.