update snippets 96-107

This commit is contained in:
Stefan Feješ
2017-12-25 14:38:49 +01:00
parent bc58a5bf54
commit 5b23bade1c
11 changed files with 61 additions and 33 deletions

View File

@ -2,11 +2,14 @@
Generates a random hexadecimal color code.
Use `Math.random` to generate a random 24-bit(6x4bits) hexadecimal number. Use bit shifting and then convert it to an hexadecimal String using `toString(16)`.
Use `Math.random` to generate a random 24-bit(6x4bits) hexadecimal number. Use bit shifting and then convert it to an hexadecimal String using `toString(16)`.
```js
const randomHexColorCode = () => '#'+(Math.random()*0xFFFFFF<<0).toString(16);
// randomHexColorCode() -> "#e34155"
// randomHexColorCode() -> "#fd73a6"
// randomHexColorCode() -> "#4144c6"
```
```js
randomHexColorCode() -> "#e34155"
randomHexColorCode() -> "#fd73a6"
randomHexColorCode() -> "#4144c6"
```