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

JavaScript - Error and Exceptions

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

    <script language="JavaScript" type="text/javascript">
        function ShowSyntaxError(){
            var x= 190;

            document.write(x);
        }

        function AddTwoNumbers(){
            try{
                var firstValue = prompt("Enter first value");
                //var secondValue = prompt("Enter second value");

                if(Number.isNaN(Number.parseInt(firstValue))){
                    alert("Please enter correct number for FirstValue");
                }
                else if(Number.isNaN(Number.parseInt(secondValue))){
                    alert("Please enter correct number for SecondValue");
                }
                else{
                    var result = Number.parseInt(firstValue) + Number.parseInt(secondValue);

                    alert(result);
                }
            }
            catch(e){
                alert("Sorry, unknown error occured: " + e.message);
            }

        }
    </script>
</head>
<body>
    <button onclick="ShowSyntaxError()">Show Syntax Error</button>

    <button onclick="AddTwoNumbers()">Show Sum</button>
</body>
</html>