javascript splash text
This is probably one of the simplest things you can add to your site with JS.
It's a random message that changes every reload!
Example:
First, we need an HTML tag that we will write the random text into:
<p id="splashText"></p>
After this, we need to make a script HTML tag, that will contain our code.
<script></script>
Inside of it, we will write as follows:
<script>
function setSplashText() {
let splashTexts = ["hello there!", "made with notepad", "scarecat wuz here"];
let splashTextElement = document.querySelector("#splashText");
let randomIndex = Math.floor(Math.random() * splashTexts.length);
let randomText = splashTexts[randomIndex];
splashTextElement.innerHTML = randomText;
}
addEventListener("DOMContentLoaded", setSplashText);
</script>
I will explain the every line of this code sometime soon. for now its a WIP to test colored code blocks :p