The program can't search the name correctly. Help!


i reviewed the code again and again. Maybe the code is not wrong. But it can't give the correct outcome.
Stuck in this project. Really need help!

Below is my code.

/*jshint multistr:true */
var text = "Hi, Ryan. I am Janet. How are you? Enjoy your time and have a nice day. Janet!";

var myName = "Janet";

var hits = [];

for (var i = 0; i < text.length; i++) {
    if ( text[i] === "J"); {
        for ( var j = i; j < i + myName.length; j++); {
if (hits.length === 0){
    console.log ("Your name wasn't found!");}
else {
    console.log (hits);


if ( text[i] === "J"); //unnecessary semi-colon
for ( var j = i; j < i + myName.length; j++); //unnecessary semi-colon

this semi-colons will interrupt your if clause and for loop


oh, I delete them and try again now. Thank you.
however, i am not clear about what situation needs an semi-colon.
sometimes it must has, sometimes it will interrupt.

do you have any suggestion?
thanks a lot


its difficult, please see this stackoverflow question


Thank you a lot.