5. Your second "for" loop


#1

SyntaxError: Unexpected identifier
Can anyone tell me what I did wrong?

/*jshint multistr:true */

var text = "Hey my name is Breana\
Breana is a name. I love the name Breana\
How are you, Breana?";

var myName= "Breana";

var hits=[];

for (var i = 0; i < text.length; i++) {
if( text[i] === 'B') {
for(var j = i; j < (myName.length + i) j++) {
hits.push(text[j]);
}
}
}


#3

"The only error is your life" !?
"learn it mate" !??

This is a place where we come for the reason to learn, so if you can help then please help and don't insult people or just tell them to "learn it".

I also did wrong in this one and I expect someone to show me how to solve it, not to tell me to "learn it mate".


#4

Funny, after "j < (myName.length + i)" should be a semicolon. learn it mate.


#5

Yes, that is why I am here. Thank you.


#6

Thank you very much, Ivan. :smile:


#7

Breana or Ivan, do either of you know what's wrong with mine?

var text = "I,Letitia, love eating chocolate. My name is Letitia.";

var myName = "Letitia";
var hits = [];
for (var i = 0; i < text.length; i++){
console.log(text[i]);

if (text[0] ==='L'){
     for (var j = i; j < (myName.length + i); j++){
         hits.push(text[j]);
         hits[0];
        }
     }
}
console.log(hits);

#8

Maybe your if statement.
Try

If(text[i] === 'L') {

I hope it helps


#9

Thank you so much! It worked!