JavaScript JavaScript Basics (Retired) Introducing JavaScript The Console Challenge

Victoria Felice
Victoria Felice
11,864 Points

Challenge: A different mistake is shown in my Javascript Console.

I downloaded project files with the 1st challenge. To my surprise, when I opened it in my browser window and used JavaScript console, a different mistake was displayed. Instead of the expected

“Uncaught SyntaxError: Unexpected identifier (scripts.js:2)” message AS in DAVE'S VIDEO, I got a

“SyntaxError: missing ) after argument list (scripts.js:2)” message both in Chrome and FireFox. It’s not my code - it’s the code I downloaded:

alert("Help me fix this program!");

alert(Can you get this message to appear?);

FF: SyntaxError: missing ) after argument list (scripts.js:2:10). Apparently, it wants me to add ) after "Can": alert(Can) you get this message to appear?);

Is anyone else getting the same error message as mine in your console? Any ideas why does my Javascript console perform differently? Thank you.

Victoria Felice
Victoria Felice
11,864 Points

After this challenge I came into conclusion that

a) You can't rely on debuggers too much.

b) FireFox console is sort of better. It gives you not only a line number but also an exact position of a “mistake” in that line.

3 Answers

Ryan Mayo
Ryan Mayo
23,604 Points

The answer that I think you are looking for is: There seem to often be differences between the downloadable code and the code used in the video. The code in the video is similar to the code that will appear in the launch-able workspace where the line was missing both quotation marks and was considered a identifier problem. The downloadable code was only missing one quotation mark. A single missing quotation mark means that javascript was making the rest of the line into a string including the ) closing bracket. So js seeing a ( opening bracket and no closing bracket, it gave you a syntax error.

Victoria Felice
Victoria Felice
11,864 Points

Thanks, Ryan for your detailed response!

I'm not sure about that, I just got an "unexpected identifier" error message. I wouldn't worry about that too much either way. Do you see the error in the code? It is missing a pair of quotes on the second alert message.

Victoria Felice
Victoria Felice
11,864 Points

Thank you. Yes, I see the obvious error. But my question is about a different outcome in JavaScript console.

I see, sorry about that. I'm not sure why you're getting a different error message. :(

Victoria Felice
Victoria Felice
11,864 Points

Thank you anyway, Cameron. I appreciate that you were trying to help me.

:)

Roland Johnson
Roland Johnson
39,580 Points

I don 't know if i'm misreading the question. The only problem I see is quotations are missing before Can and after the ? The code should be alert("Can you get this message to appear?");

Victoria Felice
Victoria Felice
11,864 Points

Thank you. But the question is about different error messages in console. Did you get the same message as Dave got in his video or mine?