randCode.js 604 Bytes
Newer Older
Soo Hyun Kim's avatar
Soo Hyun Kim committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import React, { useState } from 'react';

function randCode(){
//    const [ranNumArr,setRanNumArr] = useState([]);

    const min = 1;
    const max = 99999;
    let newNum = Math.floor((Math.random()*max)+min);
    
    // for (let i=0;i<ranNumArr.length;i++){
    //     if (ranNumArr[i]==newNum){
    //         newNum = Math.floor((Math.random()*max)+min);
    //     }
    // }
    
    let zeroSize = "";

    for (let j=0;j<5-newNum.toString().length;j++){
        zeroSize += "0";
    }

    // setRanNumArr(zeroSize+newNum);

    return (zeroSize+newNum.toString());
}

export default randCode;