Same problem as others--won't push to the array


#1

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

I've spent an hour reading other threads with this exact problem, but have not figured out the problem with my code. I HAVE to be very close. It's probably something really stupid.

var text = "All work and no play makes Bruce a dull boy. \ And when Bruce is a dull boy, he is really no fun.";
var myName = "Bruce";
var hits= [];
for (var i = 0; i<text.length; i++);
if (text[i]==="B")
for (var j = i; j < i+myName.length; j++)
    hits.push(text[j]);


#2

yep, it is something very stupid, this line:

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

the semi-colon after i++) interrupts the loop, remove the semi-colon


#3

ugh. I can't believe I wasted so much time trying to find that!!


#4

there are javascript debuggers available online, you could consider using them if you get stuck for a really long time.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.