只是想知道是否有人能弄清楚为什么我会继续获得例如。3+3=33 而不是 6。
其余的编码适用于除法,并乘以不断填塞且无法得出正确答案的加法。如果可以,请提供帮助。
这是我的代码:
<html> <head> <title>Practical Task 8 </title> </head> <body> <button onclick="myFunction()">Press & Enter First Digit & Second Digit</button> <script type="TEXT/JavaScript"> function myFunction() { var x=prompt("Please enter first number","0"); var y=prompt("Please enter second number","0"); var sum = x; var sum2 = y; var n = (x * y); var n2 = (x / y); var n3 = (x + y); document.write(sum + " + " + sum2 + " = " + n3); document.write("<BR>" + sum + " * " + sum2 + " = " + n); document.write("<BR>" + sum + " / " + sum2 + " = " + n2); } </script> </body> </html>