简体   繁体   English

JavaScript没有控制台错误

[英]JavaScript no console errors

Hello I am trying to do simple arithmetic problem checker. 您好我正在尝试做简单的算术问题检查器。 Using if, else, statements. 使用if,else,语句。 I don't get any errors on the console so I am stuck. 我在控制台上没有任何错误,所以我被卡住了。 I am at a basic level and trying to learn to debug. 我处于基本水平,正在尝试学习调试。 This is what I have so far: 这是我到目前为止的内容:

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <title>Test Your Math Skills!</title>

    <script type="text/javascript">

        /*Input: Intergers and arithmatic operator by user.
         *Processing: Compute user's input.
         *Output: Display
        */
        function mathSkills(){

        //Get intigers and arithmatic from user.
        var a = parseFloat(document.getElementById("box1")).value;
        var operator = parseFloat(document.getElementById("box2")).value;
        var b = parseFloat(document.getElementById("box3")).value;
        var result = parseFloat(document.getElementById("box4")).value;

        //Compute user inputs.

        if(a + b == result){
        window.alert("Correct! Good job.")
        }else if(a - b == result){
        window.alert("Correct! Good job.")
        }else if(a * b == result){
        window.alert("Correct! Good job.")
        }else if(a / b == result){
        window.alert("Correct! Good job.")
        }else{
        window.alert("Incorrect. Try again!")
        }
        }
        //Display message to user.
    </script>
        </head>
            <h1> Test Your Math Skills!</h1>
        <body>
            Number: <input type="text" id="box1" size="3">
            Operation:  <input type="text" id="box2" size="3">
            Number: <input type="text" id="box3" size="3">
            Result: <input type="text" id="box4" size="3">
        <button type="button" onclick="mathSkills()">Check</button>



        </body>
</html> 
 var a = parseFloat(document.getElementById("box1").value);
 var operator = parseFloat(document.getElementById("box2").value);
 var b = parseFloat(document.getElementById("box3").value);
 var result = parseFloat(document.getElementById("box4").value);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM