중첩없이 랜덤수 뽑아내기

· 11년 전 · 930
<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년 전 조회 739
11년 전 조회 3,378
11년 전 조회 864
11년 전 조회 1,046
11년 전 조회 1,743
11년 전 조회 1,008
11년 전 조회 2,488
11년 전 조회 3,082
11년 전 조회 5,765
11년 전 조회 2,118
11년 전 조회 882
11년 전 조회 1,052
11년 전 조회 931
11년 전 조회 1,426
11년 전 조회 2,233
11년 전 조회 914
11년 전 조회 1,413
11년 전 조회 1,128
11년 전 조회 1,188
11년 전 조회 1,518
11년 전 조회 1,277
11년 전 조회 2,595
11년 전 조회 1,922
11년 전 조회 1,380
11년 전 조회 1,362