개발언어/JavaScript

[JavaScript] 지정된 범위에서 난수를 발생시키는 적당한 함수 <랜덤수> 분석해보기

Roxylife 2022. 7. 30. 12:51
function randomRange(min, max) {
  return Math.floor(Math.random() * (max + 1 - min)) + min;
}

 

 

https://stackoverflow.com/questions/62981108/how-does-math-floormath-random-max-min-1-min-work-in-javascript 참고

https://stackoverflow.com/questions/17516771/javascript-random-number 참고