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


#1


https://www.codecademy.com/en/courses/javascript-beginner-en-XEDZA/0/7?curriculum_id=506324b3a7dffd00020bf661


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++); {
            hits.push(text[j]);
        }
    }
}
if (hits.length === 0){
    console.log ("Your name wasn't found!");}
else {
    console.log (hits);
}


#2

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


#3

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


#4

its difficult, please see this stackoverflow question


#5

useful!
Thank you a lot.


#6