중첩없이 랜덤수 뽑아내기

· 11년 전 · 914
<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년 전 조회 730
11년 전 조회 3,361
11년 전 조회 852
11년 전 조회 1,033
11년 전 조회 1,726
11년 전 조회 991
11년 전 조회 2,470
11년 전 조회 3,071
11년 전 조회 5,753
11년 전 조회 2,104
11년 전 조회 866
11년 전 조회 1,037
11년 전 조회 915
11년 전 조회 1,411
11년 전 조회 2,212
11년 전 조회 899
11년 전 조회 1,398
11년 전 조회 1,112
11년 전 조회 1,171
11년 전 조회 1,502
11년 전 조회 1,262
11년 전 조회 2,579
11년 전 조회 1,905
11년 전 조회 1,366
11년 전 조회 1,346