Free Puzzle Questions with Answer using Java, C#, JavaScript and PHP

JavaScript - Switch Case Statement

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script language="JavaScript" type="text/javascript">
        function TellExamStatus(){
            var grade = document.getElementById('txtGrade').value;

            switch(grade){//if(grade == 'A')
                case 'A':
                    alert("Passed, Excellent job!");
                    break;
                case 'B':
                    alert("Passed, Great job!");
                    break;
                case 'C':
                    alert("Passed");
                    break;
                default:
                    alert("Failed");
                    break;
            }
        }
    </script>
</head>
<body>
    <input type="text" id="txtGrade" />

    <button onclick="TellExamStatus()" > Tell Status</button>
</body>
</html>