중첩없이 랜덤수 뽑아내기

· 11년 전 · 906
<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년 전 조회 723
11년 전 조회 3,358
11년 전 조회 845
11년 전 조회 1,028
11년 전 조회 1,722
11년 전 조회 988
11년 전 조회 2,465
11년 전 조회 3,065
11년 전 조회 5,747
11년 전 조회 2,099
11년 전 조회 860
11년 전 조회 1,035
11년 전 조회 907
11년 전 조회 1,405
11년 전 조회 2,203
11년 전 조회 890
11년 전 조회 1,390
11년 전 조회 1,102
11년 전 조회 1,161
11년 전 조회 1,496
11년 전 조회 1,251
11년 전 조회 2,573
11년 전 조회 1,897
11년 전 조회 1,364
11년 전 조회 1,340