Times by 1000000 instead of shifting.
This commit is contained in:
@ -6,7 +6,7 @@ Use `Math.random` to generate a random 24-bit(6x4bits) hexadecimal number. Use b
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
const randomHexColorCode = () => {
|
const randomHexColorCode = () => {
|
||||||
let n = (((Math.random() * 0xfffff)) << 6).toString(16);
|
let n = (((Math.random() * 0xfffff)) * 1000000).toString(16);
|
||||||
return '#' + n.slice(0, 6);
|
return '#' + n.slice(0, 6);
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user