Victory... or not


#1



Hi guys, though I passed, I can't seem to get my name printed out! All I get is a "Your name wasn't found!" :frowning: A little help please? Thanks!


Replace this line with your code. 
var text = "hi this is ash";
var myName = "ash"
var hits = [];
for ( var i=0; i<text.length; i++){
    if ( text[i] === "a"){
        for (var k=i; k<(i+myName.length); k++){
           hits.push(text[k]);
        }
        }
} if (hits === "ash"){
    console.log(hits);
} else {
    console.log("Your name wasn't found!");
}


#2

hits is an array, so it is very unlikely it will equal a string

you could check if the length of hits was greater then zero by using .length?


#3

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