Second for loop isnt pushing anything into an array


My code keeps returning an error saying that my second for loop isnt pushing anything into the array

/*jshint multistr:true */
var text = "gevhgvszhfzshb hfhgavigsevfvks vfkghzcwfdg Max imoaksvefkhzh fkhgv Max gsvzhfgvish gvxihg Max"; 
var myName = 'Max';
var hits = [];
for(var i = 0 ; text < text.length; i++ )
    if(text[i] === "M")
        for(var j = i ; i < (myName.length + i); j++)


I think this discussion can help you out:


your first for loop, in particular the condition of your first for loop:

text < text.length

you use i to loop over your text, shouldn't you then check if i is smaller then the text length?


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