To print the string "Hello" in JavaScript, you can use the console.log()
function. This function is used to print output to the console in web browsers and other environments that support the console
object.
Here is an example of how to use the console.log()
function to print the string "Hello":
console.log("Hello");
This will print the string "Hello" to the console.
You can also use the document.write()
function to print output to the web page itself. This function is used to write HTML content to the current document.
Here is an example of how to use the document.write()
function to print the string "Hello":
document.write("Hello");
This will print the string "Hello" to the web page.
Note that the console.log()
function is generally used for debugging purposes, while the document.write()
function is typically used to generate dynamic content on the web page. In most cases, you will want to use other methods, such as the innerHTML
property or the textContent
property, to modify the content of an element on the web page.
0 Comments