Which of the following is a valid JavaScript function to output “Hello,…

2025

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

  1. A.

    console.print("Hello, World!")

  2. B.

    log.console("Hello, World!")

  3. C.

    console.log("Hello, World!")

  4. D.

    alert.console("Hello, World!")

Attempted by 71 students.

Show answer & explanation

Correct answer: C

The correct answer is Option 2. JavaScript requires console.log, not log.console.

Explore the full course: Tpsc Assistant Technical Officer