Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Liam Hayes
Liam Hayes
Full Stack JavaScript Techdegree Student 13,116 Points

Question about Syntax in JavaScript

Check this out, this is from one of the quizzes:

What is a "syntax error"?

A   A logical mistake in your programming.
B   Forgetting to add a closing <script> tag to a web page.
C   A "grammatical" mistake like mistyping a JavaScript command or forgetting a closing parentheses or quote mark.
D   Using the wrong path when linking a JavaScript file to a web page.

The correct answer is C.

My question is, how come the correct answer is not B?

It because B is in HTML? Would that be an HTML syntax error? Or would this error be a different kind of error?

Thank you!

Steven Parker
Steven Parker
220,925 Points

Can you provide link to the specific quiz? I expect there's something in the wording of how "syntax error" was defined that will distinguish the correct answer here.

1 Answer

script tags are found in HTML, and not in JavaScript. So in this case forgetting to close a script tag would be a syntax error in HTML and not in JavaScript.

Gari Merrifield
Gari Merrifield
9,571 Points

I don't think that the missing tag would generate an error itself, the error would be reported when the browser tried to interpret the HTML code following the missing script tag as JavaScript. And the page would likely stop rendering at that point. I think Poly has this nailed down, you have to consider the context, and the script tags delineate the script from the HTML, so technically, the missing tag is more likely considered a mark-up error.