Your Second "For" Loop


#1

Not sure what I'm doing wrong here. I think I'm close but needs some help.

/*jshint multistr:true */
var text = "Bennett Bennett";
var myName = "Bennett";
var hits = [];
for (var i = 0; i < text.length; i++)
if (text[i] < "B")
{ for (var j = i; j < i + myName.length; j++)
{
hits.push(text[j]);
}
}
};


#2

I think that you need to remove one "}" at the end


#3

var text = "Hey, this JS technology is craazy! Im called Boby. \
My parents call me Bob, but mostly i like Boby, because Boby \
is my name. and I dont like other names, just Boby is fine thanks.";
var myName = "Boby";
var hits = [];
for (var i = 0; i < text.length; i++) {
if (text[i] === "B") {
for (var j = i; j < i+ myName.length; j++) {
hits.push(text[j]);
}
}
}

you should try the above code...


#4

Hi. What's problem here?(SyntaxError: Unexpected token)! Thank you.

var text = "Aleksandra, Aleksandra, Aleksandra, Aleksandra";
var myName = "Aleksandra";
var hits = [];

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