What is the correct Javascript syntax to write Hello World?

279    Asked by Unnatigautam in Java , Asked on Dec 26, 2023

 I am developing a web in which I need to write “Hello world!” in the console of the browser and even on the webpage itself. How can I do so? 

Answered by Charles Parr

 You can write any phrase ( hello world! In your case) by using the “[removed]() or “console.log() method in the context of Java programming language. Here is the explanation given by using the “console.log()” and “document write ()”.

For displaying in the console of the browser

To print your required phrase or sentence on the console of the browser you can use the command

“ console.log( Hello, world!);

For displaying on the webpage

For displaying the phrase on the webpage itself, you can use the [removed]() method. Here is the example given to showcase the process:-




    Hello, World!


   
        Document.write(‘Hello, World!’);
   

These above methods will surely help you in passing your required phrase on your console of the browser and the webpage itself.



Your Answer

Interviews

Parent Categories