5/7 Can't figure out this Unexpected Token error


var text = "Yo, my name is Tanner. \
Nice to meet you.";
var myName = "Tanner"; 
var hits = []; 

for(var i = 0; i < text.length; i++) {
    if(text[i] === myName[0]) {
        for(var l = i; l < (i + myName.length; l++) {

I've compared it to other answers in the forums, so I must just be looking over something that's staring me in the face. I get an 'Unexpected Token' error. What's the issue in the code?


Try replacing the capital " I " with a " j " instead, using lowercase then uppercase I will just confuse everything. While it may seem to work, it's best to not put the chance of messing those two up.

I can't say that's the fix to your error, but it may be. Never use the same variable name, even if you're changing the capitalization of the letters. It's bad programming practice.


It's not a capital I, it's a lowercase 'L'. ^o^ But just in case that indeed confuses it anyways, I replaced the lowercase L's with j's. Still didn't work.


For the life of me I can't seem to find anything wrong with your code. You may have to simply restart your browser, sometimes the browser and the server disconnect, so the server only sees what you had before you finished your code. Otherwise I can't be sure.


you are missing a parentheses in your second for loop, after myName.length


Oh good gracious. My attention to detail has dwindled, good catch!


that's ok, haha, I find that the majority of my errors are spelling or missing special characters :smile:


Oh wow, it WAS staring me in the face! Thank you for the help, it worked. ^0^