Search Text For Your Name


My if/else statement is not working and keeps returning "unexpected token ) "

/*jshint multistr:true */
var text = "Hey how are you Alex?\
Do you want to see a movie Alex?";
var myName = "Alex"
var hits = [];
for (var i = 0; i < text.length; i++){
 if (text[i] === 'A'){
 for (var j = i; j < (i + myName.length); j++){

if(/*hits.length is 0*/) {
    console.log("Your name wasn't found!");
} else {


Hi you get this error becuase of this line

if(/*hits.length is 0*/)

you should do what the comment inside the if condition says.. with the comparison between hits.lenght and 0


Thanks yeah i just figured that out. It was those lovely little ** that kept the whole thing from working.


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