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