Which has no syntax error ?
-
alert("hello "+3+" times);
-
alert("hello "+3 times);
-
alert("hello +3+ times");
-
alert("hello "+3 +" times);
Option C is the only syntactically valid alert. The string is properly quoted and closed. Options A, B, and D have mismatched or missing quotes.
To answer this question, let's go through each option to understand why it is correct or incorrect:
Option A) alert("hello "+3+" times); - This option is incorrect because it is missing a closing quotation mark after the word "times".
Option B) alert("hello "+3 times); - This option is incorrect because it is missing a closing quotation mark after the word "times" and it does not properly concatenate the string and the number.
Option C) alert("hello +3+ times"); - This option is correct because it includes the correct syntax for concatenating a string ("hello "), a number (3), and another string (" times").
Option D) alert("hello "+3 +" times); - This option is incorrect because it is missing a closing quotation mark after the word "times".
The correct answer is C. This option has no syntax errors because it correctly concatenates the string, number, and string using the + operator and includes the necessary quotation marks.