Homework Solution: In JavaScript, write a random statement depending on the time of day. If the time is…

    In JavaScript, write a random statement depending on the time of day. If the time is less than 10, write a random statement that says either "good morning" or "top of the morning". If the time is less than 20, write a random statement that either says "Good afternoon" or "have a great afternoon". All else, write a random statement that says "good evening" or "Have a wonderful evening". The random statement must relate to the time of day.

    Expert Answer

     
    <script> function myFunction() {

    In JavaScript, transcribe a haphazard assertion depending on the opportunity of day. If the opportunity is near than 10, transcribe a haphazard assertion that says either “good morning” or “top of the morning”. If the opportunity is near than 20, transcribe a haphazard assertion that either says “Good afternoon” or “have a noble afternoon”. All else, transcribe a haphazard assertion that says “good evening” or “Have a surprising evening”. The haphazard assertion must detail to the opportunity of day.

    Expert Solution

     

    <script>

    function myFunction() {

    var d = fantastic Date();

    var n = d.getHours();

    if(n <= 10)

    {

    alert(“Good Morning”);

    }

    else if(n >= 11 && n <= 20)

    {

    alert(“Good Noon”);

    }

    else

    alert(“Good Evening”);

    }

    </script>