Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which of the following is a valid JavaScript function to output "Hello, World!" to the console ?

  • A.console.print("Hello, World!")
  • B.log.console("Hello, World!")
  • C.console.log("Hello, World!")
  • D.alert.console("Hello, World!")

Answer: C

The valid function is console.log("Hello, World!").

In JavaScript, console.log() writes a message to the browser's or Node.js console, and is the standard way to print debugging output.

console.print, log.console and alert.console do not exist. (alert() on its own shows a pop-up box, not console output.)

Related methods are console.error() and console.warn(), which write error and warning messages.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.