5/7 your second for loop


#1


/*jshint multistr:true */
var text= "yehfbrweuihfreuwhfew Rachael sedufikjshflofd Rachael";
var myName= "Rachael";
var hits = [];
for(var i=0; i < myName.length; i++);
if (text[i] === 'R') {
    for (var R = i; R < (myName.length + i); R++);
    hits.push(text[R]);
    } 

Make sure you're pushing letters to the hits array


#2

instead of myName.length try text.length


#3

Oops, try again. Careful: your second 'for' loop should stop when it reaches its current point in the string + myName.length.


#4

Ok, now looking back, all Rs need to be lower cased. the only capitol R should be in your text[i] === 'R' statement at the beginning of your if.


#5

I changed the wrong .length, i realized it was for the first loop not second. It works now!


#6

Ah! Well thats good! Sorry if I didn't clarify it enough! Happy coding


#7

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