설명

Math.random()은 JavaScript에서 난수를 생성하는 함수이다.

이 함수는 0 이상 1 미만의 난수를 반환한다.

 

[예]

1 이상 10미만의 난수 생성 

const random = parseInt(Math.random() * 10 + 1);

'JS' 카테고리의 다른 글

alert  (0) 2024.03.10
addEventListener - keydown  (0) 2024.03.10
array  (0) 2024.03.10
addEventListener  (0) 2024.03.10
control statements  (0) 2024.03.07

+ Recent posts