Why doestn work\


#1


for(var i = 0; i <= text.length; i++){
    if (text[i] === "a" ){
        if(text[i+1] === "h"){
            if(text[i+2] === "m"){
                if(text[i+3] ==="e"){
                    if (text[i+4] ==="d"){
                        hits.push(text[i,i+1,i+2,i+3,i+4]);
                        
                    }
                }
            }
        }
    }
    
    
}
//why this doesnt work


#2

i am not sure it will pass the exercise, but the code is not working because of this line:

hits.push(text[i,i+1,i+2,i+3,i+4]);

if you want to push multiply items into an array, you can, but you would need to separate the items:

hits.push(text[i],text[i+1]) # and so on

#3

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