1// 1. Using console.log()
2console.log("Hello World");
3// console.log() is used in debugging the code.
4
5// 2. Using alert()
6alert("Hello, World!");
7// // The alert() method displays an alert box over the current window with the specified message.
8
9// 3. Using document.write()
10document.write("Hello, World!");
11// // document.write() is used when you want to print the content to the HTML document.
1I would do something like this:
2
3<script>
4 alert("Hello World!");
5</script>
6
1console.log("Hello, World!");
2
3console.error("Error, World!"); // For errors
4
5console.warn("Warning, World!"); // For warnings
6
7console.clear(); // To clear the console