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.