Your second "for" loop 5/7


#1
`/*jshint multistr:true */
var text = "Hey, how are you \
doing? My name is Fate.";
var myName = "Fate";
var hits = [];
for (var i=0; i<text.length; i++) {
    if (text[i] === "F") {
        for (var j=i; j<(myName.length+i); j=++) {
        };
    };
};
console.log(hits);`

The interpreter kept saying "SyntaxError: Unexpected token )"... Please help... :frowning:


#2

Increcement in for loop should be written like so:
j++

Also, it seems that you forgot this piece of code in your second for loop:
hits.push(text[j]);


#3

Hi,
Can someone please explain the role of this piece of code " j<(i+myName.length); j++ " ?
Thank you,

Love from,
India


#4

@rashidf5

The explanation is here:

Please click on the link! :smile: