Loops - not receiving desired results


#1

var text = "Hello, This is confusing Jake. I dont know what I am doing Jake. What is going on Jake?";
var myName = "Jake";
var hits = [];

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

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

*in the console I am receiving [ ] only. need help I think its because my variable for hits is not in my loop?


#2

Try this rewrite to code but this time just write it neatly with the braces in the right place and each statement neatly written on its line
example:

for(var i = 1; i < 20; i++){
    
    if(i % 2 === 0){
        
        console.log(i);
        
    }
}

See how it is neatly written?
Perhaps writing ti that way will help you debug

Now if you want your code to look like how the one i have posted here looks like all you have to do is surround the beginning and end of your code with three backticks(reverse quotes) each like this

```
 put your code here

```