What am i doing wrong?


#1



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


Oops, try again. It looks like your second 'for' loop isn't pushing values to the hits array. Make sure it's working properly and that myName's text appears somewhere in the text variable.


var text = "my name is jack, you hear me jack"; 
var myName = "jack";
var hits = [];
for(var i = 0; i < text.length; i++){
    if( text[i] === "j" ){
        console.log("your name is in the var text");
        for(var j = i; j > i + myName.length; j++){
            hits.push(text[j]);
        }
    }
};


#2

Please see my comment behind your code.

for(var j = i; j > i + myName.length; j++) // look at the second Statement! j must be greater than myName.length + i ?  It must be smaller