5/7 no idea what's wrong!


#1



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

I have no idea what my problem is, and ive been trying to figure it out for hours now! Can anyone help?!


text = "wqdG WGVDT YEQ isaac QWDH BYUD GBU Y";
var myName = "isaac";
var hits = [];

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


#2

HI your code is fine if you want to print something you should add this line at the end of your code (after all the for loop)

console.log(hits);

#3

STILL DOESN'T WORK FOR SOME REASON! I'm stumped man!


#4

what error do you get?


#5

SyntaxError: Invalid or unexpected token


#6

Are you sure there have to be semicolons here?

text = "wqdG WGVDT YEQ isaac QWDH BYUD GBU Y";
var myName = "isaac";
var hits = [];

for ( i = 0; i < text.length ; i++) {
    if(text[i] === "i") {  
        for(var j = i; j < i + myName.length; j++) {
            hits.push(text[j]);
        };    <- here
    };        <- and here
}             <- or there is one missing here

#7

I ran you code and it worked

Try

another browser or to refresh the page


#8

Nothing happens when you delete them so idk.


#9

Could you include a screenshot like @wizmarco did?


#10

sure:


#11

sorry but try to take it after you Save and submit Code


#12

Fine:


#13

I really don't see any error ..
you could try to
add the var to

text = "wqdG WGVDT YEQ isaac QWDH BYUD GBU Y";

the same here

for ( i = 0; i < text.length ; i++)

add var to
i = 0
But did you try to refresh the page or change browser?


#14

Same here, I litteraly can not find a single difference between the versions.

But, looking at your screenshot, your code doesn't end at line 13.
Try to remove every line after line 14. I think that might be it!


#15

THAT WAS IT! Thanks so much! I didn't thing my comments would effect the code though!


#16

If they were comments (//text) they shouldn't have, but there probably something outside that.

Great work!


#17

OK well they were /* comments, is that any different?


#18

Nope, but don't forget to close them like this:

/* Comment
  Still a comment
*/ 
Not a comment

#19

OH, thats what i was doing wrong! Thanks for the help!


#20

You're weicome!:slight_smile: