5. Your second "for" loop



A message keeps coming up saying that I have a syntax error. Any suggestions?

/*jshint multistr:true */

var text = "The name is Lindsay. Lindsay enjoys reading books. Lindsay also likes running.";
var myName = "Lindsay";
var hits = [];

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


I see two problems in your code. In second inner for loop you should remove comma in second statement.
And should push values to hits array and not hit because it doesn't exist.


It seems that you have a typo in the second for loop's code block

Use hits.push(text[j]) instesd of hit.push(text[j])


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