Stuck on search text for your name


Hello, I have been stuck on this one lesson for perhap a couple months now, and just as I start to move along again I get stuck here. I did everything the instructions asked for and have no idea why it is not working. Thank you in advance

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 = "texxt text tezt text stuff text max text"
var myName = "max"
var hits = []
for (i = 0; i < text.length; i++) {console.log("i= " + i)} 
if(text[i] === 'm') {for (j = i;j <myName.length +i; j++)  {hits.push(text[j]); console.log("j= " + j) }     }


Since it complains about the array, you might start by checking what's in it after the rest of your code has run.

Then consider what series of actions should have been carried out in order to get the desired result - find out where it stops doing what you want it to do


I have tried more times than I can count. There's probably just one problem line staring me right in the face. If it is there I can't see it


It's not going to pop out at you. It may seem like that's how it works for other people, but they've just learned to do the following very quickly:

Confirm that you agree with the problem that's described. Have you done this? What was the outcome? Does something stop you from doing this?

Start somewhere in the middle of the action, is everything as it should be at this point? If so, check further ahead, otherwise, check further back. Repeat for that half of the actions. You'll have narrowed it down in a few iterations of doing this.

Before doing anything else you might fix your formatting. Your code is going to be difficult to inspect and modify when it's all crammed together. That prevents you from solving/finding the problem. And it's a fairly easy thing to improve - so it's something to get out of the way without even considering what to do after that.


Essentially, you'd need to convince me that you've exhausted the things you can do to figure it out yourself before I make any kinds of conclusions about what the problem is for you

Right now you're saying "it's not popping out at me, I can't find it"

To which I'll reply with that hey, you have to look, and here's how you look.

And if there's something stopping you from looking, then there's probably something there to learn first, right? So if there are things stopping you, identify what it is, what are you missing, and then get on that thing first.

Yes, learning how to find something may take longer than being told what to change. That's fine, that's still what you should be doing. Fill in every knowledge gap you find. If you find many gaps, all the better, you know exactly what to learn next.


Ok. I suppose I will try searching the text again. But thanks for your tip on the formatting! I always ignored the format guidelines because I never thought it would come back to bite me like now. Thanks once again. Good evening/night/afternoon/morning


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