Wednesday, February 26, 2020

Example of Switch Case

CODE:

<!DOCTYPE html>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Switch case</title>
    <script type="text/javascript">
        var day=7;
        switch(day){
            case 1: document.write("<h1>Sunday</h1>");
                break;
            case 2: document.write("<h1>Monday</h1>");
                break;
            case 3: document.write("<h1>Tuesday</h1>");
                break;
            case 4: document.write("<h1>Wednesday</h1>");
                break;
            case 5: document.write("<h1>Thursday</h1>");
                break;
            case 6: document.write("<h1>Friday</h1>");
                break;
            case 7: document.write("<h1>Saturday</h1>");
                break;
            default: document.write("<h1>Invalid day</h1>");
                break;
        }     
    </script>
</head>
<body>
   
</body>
</html>

OUTPUT:


No comments:

Post a Comment

Simple Example of div tag in html with css

HTML and CSS Code : <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <m...