Not pushing values to hit arrays


5.Your second "for" loop

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.

*jshint multistr:true */
var text= "Beyoncé’s rabid fan base stung TV chef\ Rachael Ray on social media over the weekend, \ mistaking her as fashion designer Rachel Roy, who is allegedly the\ “other woman” in Beyonce’s new infidelity anthem Sorry."
var myName= "Rachel";
var hits=[];
for(var i=0; i < myName.length ; i++);{ 
        for(var j=i; j<(myName.length+i); j++){


Might start by fixing your formatting so you don't have to squint so much while trying to read and reason about it, misdirected effort.
After that, start making observations about its behavior, what does it do differently from what it's meant to? And which part of the code is likely to be responsible for that difference, or what should your code be doing so that this difference wouldn't exist?


One way to obverse what your loops do is to just put a console.log in the first line, and see how often you get that message, just try it out!

Also, the indentations are supposed to work like this:

for(var i=0; i &lt; myName.length ; i++);{ 
        for(var j=i; j&lt;(myName.length+i); j++){


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