Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- shit-christmas
- css
- img 확대
- JS
- 무료 백엔드 배포
- improve-iq-by-up-to-10%!
- node
- css grid
- 정규표현식
- ajax
- Sass
- regExp
- es6
- Engoo
- flex-basis
- flexbox
- Node.js
- css variables
- module wrapper function
- Prototype
- Object.create
- css 오버레이
- 디자인패턴
- select by attribute
- flex-shrink
- just-one-small-sip
- flex-grow
- express-handlebars
- close together
- Express
Archives
- Today
- Total
특정 범위의 랜덤 정수 값 생성 코드 본문
Math.floor(Math.random() * (max - min + 1) + min)
나름대로의 원리
나올 수 있는 최소값이 min 이니까 Math.random()에 무슨 짓을 하든 max - min과 같은 정수를 갖는 최대값이 나와야 함(ex. 2~100 일 경우 98.99999... 까지이다., 여기에 최소값 2를 더하고 버림하면 100이 나오니까).
그러려면 max-min 값에 + 1을 해줘야 하기 때문에 위와 같은 공식이 성립된다.
'2021 프론트 엔드 로드맵 따라가기 > JS' 카테고리의 다른 글
Built in Constructor (0) | 2021.06.05 |
---|---|
Hoisting (0) | 2021.06.05 |
Number()와 parseInt() 차이 (0) | 2021.06.04 |
Local Storage & Session (0) | 2021.06.01 |
Event Bubbling & Delegation (0) | 2021.05.31 |
Comments