해결됨
모던 자바스크립트(javascript) 개발을 위한 ES6 강좌
로또 번호 생성기 소스코드
function makeLottoNumber() {
const lottoList = new Set();
while (lottoList.size < (CONFIG.bonus ? 7 : 6)) {
const random = Math.floor(Math.random() * CONFIG.maxNumber + 1);
lottoList.add(random);
}
console.log(CONFIG.title);
const result = [...lottoList];
if (CONFIG.bonus) {
const bonusNum = result.pop();
return { number: result, bonus: bonusNum };
} else {
return { number: result };
}
}
const CONFIG = {
title: "Happy Lotto Time!",
maxNumber: 45,
bonus: true,
};
console.log(makeLottoNumber());참고용으로 올립니다.