This commit is contained in:
Angelos Chalaris
2017-12-27 11:02:46 +02:00
parent 0d9b02a3cb
commit b74eb9d9bd
45 changed files with 89 additions and 91 deletions

View File

@ -6,10 +6,10 @@ Use `Math.random` to generate a random 24-bit(6x4bits) hexadecimal number. Use b
```js
const randomHexColor = () => {
let n = (Math.random()*0xfffff|0).toString(16);
return '#' + (n.length !== 6
? (Math.random()*0xf|0).toString(16) + n : n);
}
let n = (Math.random() * 0xfffff | 0).toString(16);
return '#' + (n.length !== 6
? (Math.random() * 0xf | 0).toString(16) + n : n);
};
// randomHexColorCode() -> "#e34155"
// randomHexColorCode() -> "#fd73a6"
// randomHexColorCode() -> "#4144c6"