I want to have a random number five
랜덤 숫자 5개를 찾는 소스
javascript Source implementation
var ranNum = 0
, ranVar = {}
, randomi = 0
do{
var ranNum1 = Math.floor(Math.random() * 8) + 1;
for (var k = 0; k < ranNum+1; k++)if (ranVar[k] == ranNum1 ){
ranNum = false;
}
if(ranNum != false || ranNum != "undefined"){
ranVar[ranNum] = ranNum1;
ranNum = ranNum + 1;
}
}
while (parseInt(ranNum,10) < 5); //랜덤숫자 5개만 배열로 가져옴
alert(ranVar[4]);
made by park
댓글 없음:
댓글 쓰기