SyntaxError: Invalid or unexpected token


#1


5. Your second for loop

Not getting an output despite looking and copying answers in forum. Please help find the error in this code.

var text = "Hey brother, I heard you stole my gears from George. Give them back to George you criminal.";

var myName = "George";
var hits = [];

for (var i=0; i< text.length; i++){
    if (text[i] === "G"){
        for (var j = i; j <(myName.length + i); j++){
            hits.push(text[j]);
        }
    }
}
console.log(hits);


#2

here:

console.log(hits);.

you got a . after the semi-colon, why?


#3

That was from the template not there in my code. Still doesnt work


#4

I have sorted - there was nothing wrong must have been the browser


#5

yea, it was the only thing wrong i could find. Good you sorted it :slight_smile:


#6

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