5. Your second "for" loop


#1


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

I have been looking at other posts and can't find where my code it going wrong. It is probably a little mistake and I am just not catching it so can someone please help me out? This is the error message:

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.

This is my current code:


/*jshint multistr:true */
var text = "blah blah blah hahaha \
hahaha jess hahaha blah blah what the heck \
am I doing hahahaha jess blah blah blah"

var myName = "jess";
var hits = []

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


};

Also if anyone could let me know how I would actually use the arrays and the loops in future coding that would be a great added bonus haha. Again thank you to whoever helps me!


#2

We never write a semi-colon before a block {}.


#3

I feel so stupid haha, thank you so much


#4

Be easy on yourself. It's not stupid to make a mistake, only to not care about it.

Aside:

For readability, consider writing i ++ as i++, and j ++ as j++.