Multiple choice technology web technology

3.How do you write "Hello World" in an alert box?

  1. alertBox="Hello World"

  2. alertBox("Hello World")

  3. alert("Hello World")

  4. msgBox("Hello World")

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The alert() function displays a message in a dialog box. The correct syntax is alert('Hello World') or alert("Hello World"). Options A and B use non-existent functions (alertBox), and Option D uses msgBox which is not standard JavaScript.

AI explanation

To display the message "Hello World" in an alert box, you would use the alert() function.

Let's go through each option to understand why it is correct or incorrect:

Option A) alertBox="Hello World" - This option is incorrect because there is no built-in function called alertBox(). The correct function to display an alert is alert().

Option B) alertBox("Hello World") - This option is incorrect for the same reason as Option A. There is no alertBox() function.

Option C) alert("Hello World") - This option is correct. The alert() function is used to display a message in an alert box, and "Hello World" is the message to be displayed.

Option D) msgBox("Hello World") - This option is incorrect because there is no built-in function called msgBox(). The correct function is alert().

Therefore, the correct answer is option C.