5/7 Search Text For Your Name



I've hit a wall with 5.7 adding the second for loop.. I think I have read and compared my code to every thread for this question, but I'm still none the wiser to why the second 'for' loop is not pushing values :frowning: . I really want to understand this by moving on. Can someone please assist me on this question...

*MY CODE>>>>>

var text = "bla blalknnl nlknlknklnlkn Charlotte gregerg.";
var myName = "Charlotte";
var hits = [];

for (i=10; i<text.length; i++);{
if(text[i] === myName[0]) {

for (var j = i; j < i+myName.length; j++)


if(text[i] === myName[0]) { should be if(text[i] === "C") { (Since myName starts with "C"


The jshint line should be at the very top of the code.

Multiple errors in the above line:

  • it should start at 0, not 10.
  • the token between the paren and the brace is invalid and actually terminates the loop before it even starts.
  • generally, the code does not have enough braces... There should be three pairs. for, if, for.


thank you, I think I changed this to 0 when looking at other threads.


Many thanks Roy, appreciate you taking the time to look at my code. I think I have been staring at it too long not being able to see the errors :-/ combined with comparing it to other threads regarding this question.


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