Please help!


/*jshint multistr:true */
var text = "John is not Bob, John is not text, John is a person";
var myName = "John, John, John";
var hits = [];
for (var i = 0; i < text.length; i+=1){
if (text[i] === 'j') {
for (var j = 0; j + myName.length; j ++ 1);

please help me!



The line killing the program flow is
the initialization and condition your 2nd FOR-loop.

In the first for-loop you are running over the text
* character by character using text[i] as character-value,
* comparing it to "J"

  • then in the second for-loop you have to preserve the i-variable by making the j-variable to work with.
    *var j = i ;
    *now using j you want to go over the text from position i upontill i + nameLength is reached
    -* so you have to change the condition of the second for-loop to
    -* j < i + nameLength (and do not use the less-equal-operator )

Then at the end you might want to see the result of the hits-array
console.log( hits );


google search
javascript push array
(also look in left-hand collumn Methods.... )

javascript push array