3/7 Need Help!


I Keep Getting Oops, try again. Does your 'for' loop iterate until it hits text.length? Check the Hint if you need help!
- So What Am I Doing Wrong?

var myName = "GHOST";
var hits = [];
var nameLength = myName.length
for(var i=0; i console.log(myName + hits + nameLength)


Hello blogrockstar0470,

Perhaps the web site is not displaying the entire code that you have pasted into the text box? So for the correct for loop, the question is: What do you want the program to do with your i variable? Probably, increase it by 1 in each loop. And only until the end of the array that is defined with the text variable?

So first of all, you have to specify the text variable at the beginning of your code.

Then, tell the program about the loop:

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



first off there's no need to mark a var "nameLength"
this is because we are obtaining the name when we use .length
in that way we can get the length of myName by simply typing myName.length

but besides that there are some bugs like a missing semicolon on line 3, a missing open { bracket on line 5, also check out the proper format for a for statement which is:

for (//part 1; part 2; part 3; //) {
//whatever happens when that condition is met//

part 1 is executed before the loop
part 2 is defines the loop or as long as it is true the loop will continue to run
part 3 is executed each time the loop runs

also be sure (if you are following the tutorial) to make a string containing the name you are searching for. So in your case "GHOST".

If that still doesn't help then you can check out my code and see if that helps.

/*jshint multistr:true */
var text = "So this is my text. I don't like to use my actual \
name so lets say that I am Steve. Steve is a good name, I like \
it a lot.";
var myName = "Steve";
var hits = [];
for (i=0; i<=text.length; i++) {