JS 인증번호 다섯자리 출력 코드

박현우·2024년 1월 31일

HTML_CSS_JAVASCRIPT

목록 보기
9/16
    // 두 수 사이의 난수를 리턴하는 함수
    function random(n1, n2){
       return parseInt(Math.random()*(n2-n1+1)) + n1;
    }
    // 함수 응용 -> 5자리 인증번호 생성
    let auth = "";
    for(let i=0; i<5; i++){
        auth += random(0, 9)
    }
    document.write("<h1>인증번호: " + auth + "</h1>");

0개의 댓글