Your second "for" loop PROBLEM


#1

This is the code:

for (i = 0; i >= text.length; i++) {

if (text[i] === "B") {

    for(j=i;  j < i + myName.length; j++) { 

      if (text[j] === myName[j]) {  

        hits.push(text[j])
        console.log(hits);
      }
    }


}

}

ERROR: . It looks like your second 'for' loop isn't pushing values to the hits array. Make sure it's working properly and that myName's text appears somewhere in the text variable.

where I AM DOING WRONG?


#2

take a look at the condition of your first for loop. It will evaluate to false in the first iteration

there is more code like declaring text and myName, right?


#3

I've done this:

var text = "Bogdan sfafafa Bogdan agasgag agasgasg sgfsg fgsaga Bogdan gsgasg wgfsgaeg gaweg";
var myName = "Bogdan";
var hits = [];

for (var i = 0; i < text.length; i++) {

if (text[i] === "B") {

    for(j=i;  (j < i + myName.length); j++) { 

        hits.push(text[j])
    }


}

}

and it worked


#4