728x90

Math.random()

Math.random()은 난수(랜덤 숫자)를 만든다.

 

문법

Math.random(); // default 0 ~ 1 까지 난수 생성

Math.random()*max // 0 ~ max 까지 난수 생성

(Math.random()*(max-min))+min // min ~ max 까지 난수 생성

Math.random()은 0 이상 1 미만의 난수를 만든다.

 

예제

See the Pen Untitled by Kim Jae Ik (@doitdoik) on CodePen.

728x90

+ Recent posts