HTML
<div id=”hello-world”>Hello World</div>
<script>
document.write(”Test”);
</script>
This will output the text ‘Test’ in plain text on the page. This is mainly only ever used for testing purposes. It’s important to note that using document.write after a page has loaded, will replace all of the existing HTML content that had rendered.
We can use the window.alert() method to output to an alert box. An alert box is the prompt that you see on a website that often prompts for action. Below is an example of a common prompt you might see when browsing the web.
The code snippet for this is as follows: