JavaScript选不重复随机数,下面代码有什么问题,帮忙检查下?
<script type="text/javascript">
function dianm()
{
var arr=new Array(5);
arr=["r","s","c","d","a"];
var m=0;
for(var i=0;i<5;i++)
{
if(m==1)
{
i=i-1;
m=0;
}
arr[i]=arr[Math.floor(Math.random()*5)];
for(var j=0;j<i;j++)
{
if(arr[i]==arr[j])
{
m=1;
}
}
if(m==0)
{
alert(arr[i]);
}
}
}
</script>