중첩없이 랜덤수 뽑아내기

· 11년 전 · 884
<script> 
function setRand(min,max,number) { 
    randResult = new Array(); 
    randList = new Array(); 
    for(i = min; i <= max; i++) { 
randList.push(i); 
    } 

    for(i = 0; i < number; i++) { 
getRand(); 
    } 
    alert(randResult); 

function getRand() { 
    randNumber = Math.floor(Math.random() * randList.length); 
    randResult.push(randList[randNumber]); 
    randList.splice(randNumber,1); 

//Min, Max, Number 
setRand(7,10,3); 
</script> 

|
댓글을 작성하시려면 로그인이 필요합니다.

팁게시판

디자인과 관련된 유용한 정보를 공유하세요. 질문은 상단의 QA에서 해주시기 바랍니다.

+
제목 글쓴이 날짜 조회
11년 전 조회 699
11년 전 조회 3,334
11년 전 조회 819
11년 전 조회 1,004
11년 전 조회 1,697
11년 전 조회 963
11년 전 조회 2,438
11년 전 조회 3,042
11년 전 조회 5,726
11년 전 조회 2,073
11년 전 조회 833
11년 전 조회 1,012
11년 전 조회 885
11년 전 조회 1,382
11년 전 조회 2,179
11년 전 조회 865
11년 전 조회 1,368
11년 전 조회 1,075
11년 전 조회 1,131
11년 전 조회 1,470
11년 전 조회 1,226
11년 전 조회 2,548
11년 전 조회 1,871
11년 전 조회 1,333
11년 전 조회 1,314