if else if

try here:

https://www.w3schools.com/js/tryit.asp?filename=tryjs_ifthenelse


code:

<!DOCTYPE html>
<html>
<body>

<p>Click the button to display a time-based greeting:</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
    var hour = new Date().getHours(); 
    var greeting;
    if (hour < 12) {
        greeting = "Good morning";
    } else if ( hour<16 ) {
    
     greeting = "Good afternoon";
    
    } else {
        greeting = "Good evening";
    }
    document.getElementById("demo").innerHTML = hour + "<br>"+greeting;
}
</script>

</body>
</html>