5. What`s wrong?


#1


https://www.codecademy.com/en/courses/javascript-beginner-en-XEDZA/0/4?curriculum_id=506324b3a7dffd00020bf661

Oops, try again. There was a problem with your syntax.


Here is my code, I don't know what's wrong with it, please help.

/*jshint multistr:true */
var text = "toc toc toc toc toc toc toc \
My name is Larisson";
var myName = "Larisson";
var hits = [];
for(var i = 0; i < text.length; i++) {
    if text[i] === "L" {
        for(var i = j; j < (myName.length + 1); j++) {
            hits.push(text[j])
        }
    }
}


#2

should be,

myName.length + i

or

i + myName.length

#3

I change but don`t works :frowning:


#4

Does it look like this, now?

for (var j = i; j < i + myName.length; j++) {

#5

No!
for(var i = j; j < myName.length + i; j++)


#6

I changed the i =j to j = i but didn`t works


#7

Please re-post your code and the error message you are getting. Thank you.


#8

/*jshint multistr:true */
var text = "toc toc toc toc toc toc toc \
My name is Larisson";
var myName = "Larisson";
var hits = [];
for(var i = 0; i < text.length; i++) {
    if text[i] === "L" {
        for (var j = i; j < i + myName.length; j++) {
            hits.push(text[j])
        }
    }
}

the message: SyntaxError: Unexpected identifier


#9

It would appear that the parser is not recognizing the continuation operator, though I cannot fathom that. We can find out by putting all the text on a single line and removing the operator, \


#10

I remove, but don`t works :frowning:


#11

\o/ I put and worked

var text = "toc toc toc toc My name is Larisson";
var myName = "Larisson";
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])
}
}
}