0
I have an exercise to do the four basic operations, but multiplication/division is not going, and you have to test if the number q is dividing is not zero. However certain sum and subtraction.
<html>
    <head>
        <title> Primeiro Projeto</title>
        <meta charset="utf-8">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>    
        <script type="text/javascript">
            function calcSoma(){
                var a=$("#num1").val(); 
                var b=$("#num2").val();
                var c= parseInt(a)+parseInt(b);
                $("#num3").val(c);
            }
            function calcSub(){
                var a=$("#num1").val(); 
                var b=$("#num2").val();
                var c= parseInt(a)-parseInt(b);
                $("#num3").val(c);
            }
            function calcDiv(){
                var a=$("num1").val();
                var b=$("num2").val();
                if(b != "0"){
                    var c= parseInt(a)/parseInt(b);
                    $("#num3").val(c);
                }else{
                    $("#num3").val("Dividendo é 0");                    
                }
            }
            function calcMult(){
                var a=$("num1").val();
                var b=$("num2").val();
                var c= parseFloat(a)*parseFloat(b);
                $("#num3").val(c);
            }
        </script>
    </head>
    <body>
        Número1: <input type="text" size="2px" id="num1"><br>
        Número2: <input type="text" size="2px" id="num2"><br>       
        <button onclick="calcSoma()">+</button>
        <button onclick="calcSub()">-</button>
        <button onclick="calcDiv()">/</button>
        <button onclick="calcMult()">*</button><br>
        Resultado:<input type="text" size="2px" id="num3">
    </body>
</html>
I can’t believe I was racking my brain over this :/. Thank you!
– ProgMen
If it helped you, give a upvote. If you’ve solved your problem, mark your answer.
– user86792
I didn’t know about this rule of syntax, it helps well, and it makes the code cleaner. It just makes it right. Vlw
– ProgMen
Good luck! If you can study Jon Ducket’s book on Javascript. It’s worth it!
– user86792