Skip to content

Commit 62fbd93

Browse files
committed
hex color generator
1 parent a751b4b commit 62fbd93

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

javascript-question/hexColoeGne.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// const hexColorGenerator = () => {
2+
// const str = "0123456789abcdef";
3+
// let color = "#";
4+
// for(let i = 0;i<5;i++){
5+
// let randomIndex = Math.floor(Math.random() * str.length);
6+
// color+=str.charAt(randomIndex);
7+
// }
8+
// console.log(color)
9+
// return color;
10+
// }
11+
12+
const randomHexGen = () => {
13+
return `#${Math.random().toString(16).slice(2,8).padEnd(6,0)}`;
14+
}
15+
16+
console.log(randomHexGen());

0 commit comments

Comments
 (0)