我尝试提示输入,然后比较两个值:
var x,y;
x = prompt("enter the first value","");
x = prompt("enter the second value","");
if( x > y)
{
alert("x>y");
}
else if(x < y)
{
alert("y>x")
}
else
{
alert("error");
}每次运行此命令时,都会命中alert("error")行。我做错了什么?
发布于 2011-02-10 08:52:59
您没有分配y
x=prompt("enter the first value","");
x=prompt("enter the second value","");这两种赋值都分配了x。
发布于 2011-02-10 08:53:28
打字错误:
x=prompt("enter the first value","");
y=prompt("enter the second value","");发布于 2011-02-10 08:53:19
您的第二行应该设置y而不是x。
https://stackoverflow.com/questions/4952281
复制相似问题