Stuck on 6


#1


keeps saying
Oops, try again. There was a problem with your syntax.
please help


var text = "hello some name Mustafa hello some name Mustafa ";
var myName = "Mustafa";
var hits = [];

for (i=0; i<text.length; i++) {
    if(text[i] === "M"){
        for(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

Hi this line

if(hits.length = 0)

you should change the = with ===


#3

Still doesnt work please help


#4

this line remove the ;

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

#5

Still doesnt work

SyntaxError: Unexpected end of input


#6

you should close the else statement

else{
    console.log(hits);

with }


#7

Thanks alot it worked


#8

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