Search the Community
Showing results for tags 'arithmetic opeartion'.
-
Hello Gurus, I'm a beginner to the Java Script. While learning Arithmetic chapter, I just tried the below simple program. Everything is giving correct result except the addition operation. I tried my best to understand and produce the result. Could anyone point out/throw some light on what I'm doing wrong please. <!DOCTYPE html> <html> <body> <h1>Assigning Values</h1> <p>In JavaScript the = operator is used to assign values to variables.</p> <input type="number" id="a" value=5></input> <input type="number" id="b" value=1></input> <p id="+"></p> <p id="-"></p> <p id="YY"></p> <p id="*"></p> <p id="/"></p> <script> var x = document.getElementById( "a" ).value; var y = document.getElementById( 'b' ).value; //document.getElementById("+").innerHTML = "Additon - " + (x + y) + typeof x; //document.getElementById("+").innerHTML = (x + y) + " - Additon" ; //document.getElementById("+").innerHTML = x + y; document.getElementById("+").innerHTML = Number(x) + y; document.getElementById("-").innerHTML = x - y ; document.getElementById("YY").innerHTML = "Subtraction - " + x - y ; document.getElementById("*").innerHTML = "Multiplication - " + x * y; document.getElementById("/").innerHTML = "Divide - " + x / y; </script> </body> </html> Thanks in Advance. Regards, Md.Riyaz
- 4 replies
-
- java script
- addition
-
(and 1 more)
Tagged with: