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
- css
- flex-shrink
- es6
- shit-christmas
- JS
- flexbox
- flex-grow
- regExp
- ajax
- Prototype
- 무료 백엔드 배포
- express-handlebars
- just-one-small-sip
- flex-basis
- css grid
- Express
- Engoo
- select by attribute
- css 오버레이
- img 확대
- Object.create
- node
- css variables
- module wrapper function
- 정규표현식
- Node.js
- improve-iq-by-up-to-10%!
- Sass
- close together
- 디자인패턴
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