I'm stuck at "Your Second For loop"


#1

I'm getting this Error message:
SyntaxError: Unexpected identifier

This is my code:

/*jshint multistr:true */
var text = "Hello There my name is Linus, \
Have you heard of me? i'm quite special";
var myName = "Linus";
var hits = [];
for (var i = 0; i < text.length; i++) {
    if (text[i] === "L") {
        for (var j = i; j < (myName.length + i) j++);
 }
};

.

Please help.-.


#2

You've forgotten the hits.push... line

and also you need an opening bracket for your second loop as well as a closing one.


#3

Is it supposed to look like this?
...
/*jshint multistr:true */
var text = "Hello There my name is Linus, \
Have you heard of me? i'm quite special";
var myName = "Linus";
var hits = [];
for (var i = 0; i < text.length; i++) {
if (text[i] === "L") {
for (var j = i; j < (myName.length + i) j++); {
hits.push(text[j]);
}
}
};
...
cuz i'm still getting the same error


#4

This part should looklike,

j < i + myName.length;


#5

Thank you very much for your help.


#6

You're welcome :grin:


#8

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