Print Strings with alert() method
We can provide strings in pop up dialogue box. It can be shown using any of the alert, prompt or confirm method.
Example: The below code implements alert box to print the string in dialog box.
<!DOCTYPE html>
<html>
<body>
<h2>Hello,w3wiki</h2>
</body>
<script>
alert("Hello Geeks!");
</script>
</html>
Output:
How to Print a String in JavaScript ?
In JavaScript, printing a string means displaying the contents of a string variable or literal to the console, webpage, or any other output medium. Strings are a fundamental data type in JavaScript, representing sequences of characters enclosed within single (”) or double (“”) quotes.
Table of Content
- Print Strings on Console
- Print Strings on webpage
- Print Strings with alert() method