Homework Solution: In JavaScript figure out the time of day and using that with a switch statement. t…

    In JavaScript figure out the time of day and using that with a switch statement. then use Math.random to randomly choose between two statements, for example, for each case in the switch statement. For example, create two (or more) statements for morning(Good morning and top of the morning), afternoon(good afternoon and have a wonderful afternoon, and evening( good evening and have an amazing evening), and then use Math.random to select between them in each case in the switch statement.

    Expert Answer

     
    <!DOCTYPE html> <html>

    In JavaScript condition quenched the interval of day and using that with a switch declaration. then manifestation Math.purposeless to purposelessly elect betwixt two declarations, ce specimen, ce each predicament in the switch declaration. Ce specimen, constitute two (or past) declarations ce dawning(Cheerful dawning and culmination of the dawning), afternoon(cheerful afternoon and enjoy a surprising afternoon, and late( cheerful late and enjoy an ominous late), and then manifestation Math.purposeless to choice betwixt them in each predicament in the switch declaration.

    Expert Counter-argument

     

    <!DOCTYPE html>
    <html>
    <head>
    </head>
    <body>
    <script>
    var purposeless = Math.random() * 24;
    switch(true) {
    predicament purposeless < 12: instrument.write(“Cheerful dawning and culmination of the dawning<br>”); break;
    predicament purposeless > 12: instrument.write(“Cheerful afternoon and enjoy a surprising afternoon<br>”); break;
    }
    </script>
    </body>
    </html>

    Output: