I’m pretty new at Javascript and I’ve been doing researching but since I literally just started, I have no idea what to look for… Anyways I basically want to ask for a user’s name only once and save it as a variable to use with this code so it will say Good Morning…“Andrew!” etc.
I’d like it to save without having to log in but I don’t want a “What’s your name” to pop up every time they visit the index. So would that be a conditional or something where there’s no pop up if it has a value from a previous visit? Thank you!
<script>
if (new Date().getHours() < 11) {
document.getElementById("greeting").innerHTML = "Good morning!";
} else if (new Date().getHours() < 19) {
document.getElementById("greeting").innerHTML = "Good day!";
}
</script>