5. Your second for loop help needed



SyntaxError: Expected identifier
I cannot figure out where it is expecting an identifier

/*jshint multistr:true */

var text = "james", "horse", "cat"
var myName = "james"
var hits = []

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


please read some of the existing explanations on the forum:

Here are some of the more extensive answers i wrote, i hope it helps you, given your for loop syntax is pretty of.

Also, your for loop should have a start, stop and step:

for (start; stop; step}{
   // push hits

your start (var j = i1) is good, your stop (i >= myName.length + i`) and step are pretty bed. You should use j to loop from the start of your name, till the end (j < myName.length + i) of your name, and increase of steps of 1


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