The second For loop (what the hell am I missing?)


#1


/*jshint multistr:true */

var text = "boop boop boop boop boop Matt boop boop boop Matt boop boop Matt boop boop boop Matt";
var myName = "Matt";
var hits = [];
for(var i = 0; i < text.length; i++) {
    if(text[0] === "M") {
    for(var x = i; x < myName.length + i; x++) {
      hits.push(text[x]);
       }
    }
}


#2

You need a semi colon after the last closing bracket.


#3

And this line should refer to i as in if(text[i] === "M") and not if(text[0] === "M")


#4

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