Math对象求错误?

来源:百度知道 编辑:UC知道 时间:2024/05/20 11:01:16
到底问题出在哪儿,搞了半天
<html>
<head><title>Math对象</title>
<script language="javascript">
con=true;
while(con==true);
{
//下面利用Math对象的random() 方法产生3个随机数
r1=Math.round(Math.random()*10);
r2=Math.round(Math.random()*10);
r3=Math.round(Math.random()*10);
result1=prompt(String(r1)+"+"+String(r2)+"+"+String(r3)+"=?","写出结果");
result2=r1+r2+r3;
if(Number(result1)==result2)
{
con=confirm("你真聪明,答对了,在来一遍吗?");
if (con==false)
{alert("欢迎下次在来");break;}}
else
{con=confirm("你没答对,在来一遍吗?");
if(con==flash)
{alert("欢迎下次在来。");break;}}
}
</script>
</head>
</html>

你写的这个代码块,基本上没有什么问题,只是,有两处语法错误!
1.在倒数6行处->if(con==flash) 此处,应该是false.
2.在使用while循环时,语法的使用通常是while(条件){ //循环代码}
while拼写没问题,就是括号后,没有逗号‘,’;
所以,修改过来就没什么事了。。
接受数值的“提示文字”,三个随机数不用转换,通过+"+"+等字符串,连加就自动转换了!!
祝你早日,精通HTML。。 嘻嘻……