()
| 1 | const hexValueElement = document.querySelector('.hex-value'); |
| 2 | |
| 3 | function generateHEX(){ |
| 4 | let randomHex = |
| 5 | Math.random() //random number between 0 and 1 |
| 6 | .toString(16) //convert that number to hexadecimal string (i.e, base 16) |
| 7 | .substr(-6); //grab last 6 digit string |
| 8 | let randomHexColor = `#${randomHex}`; |
| 9 | hexValueElement.textContent = randomHexColor; |
| 10 | document.body.style.background = randomHexColor; |
| 11 | } |
| 12 | |
| 13 | function keybord(event){ |
| 14 | if(event.code == 'Space'){ |