嘿,我做了一个 javascript 计算器,想要尝试 5 + 5 它给我 55 其他然后 10?但是,如果我尝试 5 / 5 它会给我 1 罚款,如果我尝试 5 - 5 它会给我 0 罚款,并且与时间相同我不理解我的代码的问题也想尝试 console.log 它没有工作,所以我使用 document.write
这是我的代码
var Plus = function()
{
var N1 = prompt("Enter first number");
var N2 = prompt("Enter second number");
var sum = (N1 + N2);
document.write(sum);
}
var Minus = function()
{
var N1 = prompt("Enter first number");
var N2 = prompt("Enter second number");
var sum = (N1 - N2);
document.write(sum);
}
var Division = function()
{
var N1 = prompt("Enter first number");
var N2 = prompt("Enter second number");
var sum = (N1 / N2);
document.write(sum);
}
var Times = function()
{
var N1 = prompt("Enter first number");
var N2 = prompt("Enter second number");
var sum = (N1 * N2);
document.write(sum);
}
var Answer = prompt("Plus ?, Minus ?, Division ? or Times ?");
if( Answer === "Plus")
{
Plus();
}
else
{
if( Answer === "Minus")
{
Minus();
}
else
{
if( Answer === "Division")
{
Division();
}
else
{
if( Answer === "Times")
{
Times();
}
else
{
document.write("How did you get here?");
}
}
}
}