如下圖所示function doubleChromosphere() { var bools = [], i, ranNumber; for(i = 0; i < 5;) { ranNumber = parseInt(Math.random() * 33 + 1); if(bools.indexOf(ranNumber) == -1) { bools.push(ranNumber); i++; } } var str = ""; for(var j = 0; j < bools.length; j++){ str += bools[j] + " "; } red.innerHTML = str.toString(); blue.innerHTML = (parseInt(Math.random() * 16 + 1)).toString(); }
這個(gè)雙色球代碼會(huì)出現(xiàn)重復(fù)數(shù)字嗎
三國(guó)紛爭(zhēng)
2018-11-09 14:11:59