-
카테고리
-
세부 분야
프로그래밍 언어
-
해결 여부
미해결
[로또생성기] 제 답안 공유드립니다!(저같은 독학러 도움이 되실까하여..)
19.08.27 01:18 작성 조회수 141
5
const SETTING = {
name : "LUCKY LOTTO",
count : 6,
maxNumber : 45
};
const {count, maxNumber} = SETTING;
const lotto = new Set();
function getRandomNumbers(maxNum) {
while(lotto.size < count) {
const randNum = Math.floor(Math.random() * (maxNum - 1)) + 1;
if (!lotto.has(randNum)) {
lotto.add(randNum);
}
}
}
getRandomNumbers(maxNumber);
lotto.forEach(n => {console.log(n)});
답변을 작성해보세요.
답변 0