6/7 t looks like your second 'for' loop isn't pushing values to the hits array


#1

Seriously stuck here. I've searched other 6/7 answers in the thread, but I'm not sure what I'm doing wrong. Getting the error message "t 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."

Here's my code:

/*jshint multistr:true */
text = "Hey, how's it going? My name is \ Charline.";
var myName = "Charline";
var hits = [];
for(var i=0; i< text.length; i++){
if(text[i] ==='J'){
for(var j=i; j < (i+myName.length);j++){
hits.push(text[j])

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


#2

Hi, please put 'J' in your text .


#3

...Oy. I knew it was something small I was missing. Thanks!!


#4

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

//try that it works