Oops, try again. Make sure you're pushing letters to the hits array!


#1

im stuck on the 5th stage of Search text for your name

i keep getting the error message "Oops, try again. Make sure you're pushing letters to the hits array!"


var text = " yyj ghg jyg kjg khg Sam jmj ytf \
jtd fhb fdb Sam jiv uch vcg vcy Sam ctb fct ccg";

var myName = "Sam";
var hits = [];

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


#2

On this line, you don't need to include myName, but instead replace it with the variable text ,

hits.push(text[j]);


#3

ah, thanks. just made one of those silly mistakes. thanks a lot for the help.


#4

You're welcome. :grin:


#5

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