Help please second loop


#1



won't push values into the hits array

Here is the edited code.


var text = "Blah blah blah blah Matthew blah \
blah blah blah blah Matthew blah blah blah blah \
blah Matthew blah blah blah blah blah blah blah"
var myName = "Matthew"
var hits = [];

for (var i = 0; i < text.length; i++) {
    if(text[i] === myName[0]) {
    for (var j = i; j < (myName.length + i); j++) {
    hits.push(text[j]);    
    }
  }
}


#2

Check your comparison operators


#3

it now works, the problem was the comparison of the j value, so the greater than sign got changed to a less than sign for those with the same problem