Allowed me to move from to "Log it!" but


#1

I was allowed to move from "5. Your Second 'for' Loop" so I figure my code was okay. Nevertheless, I cannot figure out what I am doing wrong in "6. Log it!" This section seems so easy, but I keep getting an "unexpected token ;" error.

Can someone help?


var text = "The quick, red Scot jumped over the tall, green hedge.\ Now is the time for every Scot to come to the aid of his country.";

var myName = "Scot";

var hits = [];

for (var i = 0; i < text.length; i++) {

    if (text[i] === "S") {

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

    } else {

        console.log(hits);
}


#2

You should check on all of your sets of { and }. You must have matching pairs.


#3

Thank you for your response. But I count 8 open braces and 8 closed. Hence, my puzzlement. So if the count matches up, I don't have one left open. Does their position have anything to do with it? If I misplace them (despite having the same number of each), will this deliver this same error message?


#4

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