JavaScript lines end with what

  1. comma

  2. semicolon

  3. colon

  4. Bracket


Correct Option: B

AI Explanation

To answer this question, we need to understand the syntax of JavaScript.

In JavaScript, statements or lines of code are typically terminated with a semicolon (;). This is used to indicate the end of the statement and separate multiple statements on the same line. The semicolon is a crucial component of JavaScript syntax and is used to avoid any potential ambiguity or errors.

Let's go through each option to understand why they are correct or incorrect:

Option A) Comma - This option is incorrect because commas are not used to end lines in JavaScript. Instead, commas are used to separate items in a list or arguments in a function.

Option B) Semicolon - This option is correct because semicolons are used to terminate statements and end lines in JavaScript.

Option C) Colon - This option is incorrect because colons are typically used for object property assignments and in JavaScript's ternary operator, but they are not used to end lines.

Option D) Bracket - This option is incorrect because brackets (either curly brackets {} or square brackets []) are used for grouping code blocks, defining arrays, or creating objects, but they are not used to end lines.

Therefore, the correct answer is B) semicolon. This option is correct because semicolons are used to terminate statements and end lines in JavaScript.

Find more quizzes: