Second for loop


for(var i = 0; i > text.length; i++){
    if(text[i] === 'g'){
        for(var j = i; j < i + myName.length; j++){

what is wrong in this code. plz help me the error is
Oops, try again. 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.


After testing your code I think your only error is in for(var i = 0; i > text.length; i++).
It should be for(var i = 0; i < text.length; i++) because if you say that i > text.length you actually say "Ok, run until this condition is true." and your condition is never true.


Yaah! thank you so much.. im such an idiot i didnt saw that one.:slight_smile:
thank you!


Don't worry, it happens. :wink: You got the harder part right and it's more important.


yes you are right:) anyway thanks once again.


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