Stuck at the second loop


So it is saying that I am not pushing the code, but I believe I have it correct. I don't have a very good understanding of for loops to begin with, so it may be incorrect.

/*jshint multistr:true */

var text = "The quick brown fox jumped over the James lazy dog."
var myName = "James"
var hits = []

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


Push an item from the string...



So I see that that works, but why couldn't it be text[i] if I said that j=i?


Because i is static during the operation of loop. j is incrementing, so will access all five letters.


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