5/7 hits to the array


#1

I have literally read every single post here about this section and am completely lost at this point. On a positive note, I now understand the reasons behind the j<(myName.length +1). Thank you for all the lovely explanations around that issue.

so, my issue is this: When I type the code exactly as the example in the previous lessons or even when I adjust to the examples here in the forums, I am always confronted with: "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."

I have done a literal line by line comparison by copying and pasting the example code above mine and making sure everything, including the spaces are exactly the same, changing only my name. But I get that error message every time.
Here is my code:

var text = blah blah
var myName = "Randi";
var hits = [];

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

the text i used for my var text is a long piece of Lorem Ipsum that i didn't feel needed to be added here, but it is correctly "..." and has a ; at the end.

The funny thing with this piece of code is that when I do this

 if (text[i] === "R"); {

with an obviously misplaced ; the lesson completes and sends me on.

I know it's been asked before (many times), but am I or what am I doing wrong?

Thank you!


#2

Given all the correct code, we still cannot pass this if we don't have at least something in the hits array. Use the sample text from lesson 1 by replacing Eric with Randi.


#3

your missing a } at the end of your program