Javascript

javascript - random color code

yemsu 2020. 9. 22. 13:02

const getRandomColor = '#' + Math.floor(Math.random() * 16777215).toString(16)

랜덤 컬러 값 얻을 때 쓰는 코드.  


16777215를 hex로 표현하면 ffffff가 된다고 한다.

자세한 설명은 아래페이지 참고

https://namu.wiki/w/%ED%97%A5%EC%8A%A4%20%EC%BD%94%EB%93%9C