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

Inflearn Community Q&A

islendboy0564's profile image
islendboy0564

asked

ES6 course for modern javascript development

Lotto Number Generator

그냥 생각 대로 만들어봤습니다.

Written on

·

198

1

const SETTING = {
  name: 'LUCKY LOTTO',
  count: 6,
  maxNumber: 45
};

function getRandomNumber(setObj) {
  const rNum = Math.floor(Math.random() * SETTING.maxNumber + 1);
  setObj.add(rNum);
  //랜덤한 유일한 숫자값을 추출
  while (SETTING.count > setObj.size) {
    this.getRandomNumber(setObj);
  }
  return setObj;
}

const lottoSet = new Set();
  const rs = this.getRandomNumber(lottoSet);

console.log(Array.from(rs).sort((a, b) => a - b).join(' , '));
es6javascript

Answer

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

asked

Ask a question