Multiple choice javascript

What is the correct JavaScript syntax to write "Hello World"?

  1. response.write("Hello World")

  2. document.write("Hello World")

  3. ("Hello World")

  4. echo("Hello World")

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

In client-side JavaScript, the correct method to write output to the HTML document is document.write(). The response.write() method is used in server-side ASP/VBScript, not JavaScript. Parentheses alone don't output anything, and echo() is a PHP construct, not JavaScript.

AI explanation

In JavaScript, document.write() is the method used to write output directly into the HTML document, so document.write("Hello World") is the correct syntax to output that text. response.write is an ASP/server-side construct, not JavaScript, and the other options aren't valid JavaScript statements at all.