인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

shiikong8162's profile image
shiikong8162

asked

ES6 course for modern javascript development

Lotto Number Generator

도움될까 해서 올립니다.

Resolved

Written on

·

238

2

    const SETTING = {
        name: "LOTTO",
        count: 6,
        maxNum: 45
    }

    function getRandomNum() {
        const arrRanNum = new Set();
        const {countmaxNum} = SETTING;

        while(arrRanNum.size < count){
        const num = Math.floor(Math.random() * maxNum) + 1;
        console.log(num); // 랜덤 확인
        arrRanNum.add(num);
        }
        return Array.from(arrRanNum);
    }

    console.log(getRandomNum());

더 좋은 방법이 있을까 궁금하네요

javascriptes6

Answer

This question is waiting for answers
Be the first to answer!
shiikong8162's profile image
shiikong8162

asked

Ask a question