"YOUR second "FOR"LOOP


hello, I just don't understand where i went wrong here please explain here is my code:

var text = "Hi my name is Shon./I love code and because of this/Shon love code and nobody else but Shon.";
var myName = "Shon";
var hits =[];
for ( var i = 0; i < text.length; i++){
if(text[i] ==='S'){
for ( var j = i; j < (i + myName.length); j++);


if(hits.length === 0){
console.log("Your name wasn't found!");


No SEMI COLONS after LOOPS. That's a frequent saying I have to say. :smiley:

You also need two corresponding brackets for this for loop.


Any assistance? The loop is not stopping where I need it to :

var text = "hello everyone Mick is the the house \
and he is living life large like a Mick should";
var myName = "Mick";
var hits = [];
for(var i = 0; i < text.length; i++) {if(text[i] === "M");
{for(var j = i;j < myName.length; j++) {hits.push('Mick')}}

Much appreciated team.


Oooook. First of all, I will say something I say A LOT of times. Do NOT put semi colons AFTER the loop. For example:

See that semi colon at the end, and which was bolded, not italicized? That is a problem, for what the semi colon is used for is to END the function. Basically, it's like a disconnector.

Also, you're supposed to not push "Mick", but j. Why? Because the second for loop you made uses j to find the other letters of myName and searches it one by one on the text if the first for loop had found the first letter!


NO semicolons(:wink: after loops..!!!
correct it and 'save & submit'...!


Thanks for your help.