Your second for loop


var text = "hey how are you My name is joseph" ;
var myName = "joseph";
var hits =[];
for(var i = 0; j< text.length; i++){
if (text[i] ==="j"){
for (var j=i; j hits.push(text[j])
My code


Is there anything you would like to ask? It's unclear what the purpose of the thread is.


sorry i want too see what is wrong with my code


Why do you say that there is something wrong with it? Does it not behave like you want? If so, what does it do differently? We can't guess what your code is meant to do, only you know that.


this is the error: 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.


Then you might want to start by running the code and printing out that array afterwards to confirm whether that is the problem.

If it is, then you might want to add more prints in the code to find out why it isn't reaching the statement that adds characters to the array.


You started your iteration with 'i' and then you jumped to j in your for loop


what do i need to change


its okay i figured it out


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