5/7 help?


#1

var myName="Marius"
var hits=[]
for (var i=0; i{
if (text[0]==="M")
{
for(var j=i; j {
hits.push(text[j]);
}
}
}
Hi can someone see what im doing wrong here. It says it looks likeyour second for loop isn't pushing values to the hits array. I'm not sure what the problem is? Thanks


#2

Have a read
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for
You are missing the condition in your fFOR-definition


#3

Sorry that didn't copy over correctly. Could you have a look at this and see what the problem is?
var myName="Marius"
var hits=[]
for (var i=0; i<
text.length; i++
){if (text[0]==="M")
{for(var j=i; j<
myName.length+i,j++)
{hits.push(text[j]);
}
}
}


#4

var myName="Marius"
var hits=[]
for (var i=0; i<
text.length; i++
){if (text[0]==="M") //replace text[0] with text[i]
{for(var j=i; j<
myName.length+i,j++) //replace the comma with semi-colon
{hits.push(text[j]);
}
}
}
//add a console.log()
console.log( hits );


#5

Thanks very much leonhard, I got there eventually