題目要求是在script標(biāo)簽內(nèi),使用random ()方法和round(),計算不大于10的整數(shù)。下面是我的代碼,編蒙了,誰來幫我看一下。<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Math </title><script type="text/javascript">//循環(huán)??? var k = 0;??? while(1){?????? ?//生成10以內(nèi)的整數(shù)??? var a = Math.random()*10;??? var b = Math.round(a);??? document.write(b);//放入數(shù)組arr??? c[k] = b;??? k++;?? ?//數(shù)組去重??? function only(){??? for(i in c){??????? if(var j=c.indexOf(b)){??????????? if(var l=c.indexOf(b,j+1)>=0){??????????????? c[l] = "";??????????????? only();??????????? }??????? }??? }??? }//如果arr.length==11,循環(huán)結(jié)束??? if(k==10) break;//排序并輸出arr數(shù)組??? c.sort();??? document.write(c);??? }</script></head><body></body></html>
請問程序錯在哪里?
ffff團(tuán)4346595
2016-11-15 21:26:35