중첩없이 랜덤수 뽑아내기

· 11년 전 · 918
<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년 전 조회 731
11년 전 조회 3,365
11년 전 조회 856
11년 전 조회 1,036
11년 전 조회 1,731
11년 전 조회 996
11년 전 조회 2,475
11년 전 조회 3,075
11년 전 조회 5,757
11년 전 조회 2,108
11년 전 조회 867
11년 전 조회 1,042
11년 전 조회 919
11년 전 조회 1,414
11년 전 조회 2,215
11년 전 조회 899
11년 전 조회 1,401
11년 전 조회 1,113
11년 전 조회 1,174
11년 전 조회 1,505
11년 전 조회 1,265
11년 전 조회 2,581
11년 전 조회 1,906
11년 전 조회 1,369
11년 전 조회 1,347