Last active
June 17, 2021 22:56
-
-
Save Shivabeach/f29906c4949ee22b9ba964eca28ddb38 to your computer and use it in GitHub Desktop.
Create random colors with Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let backg = document.getElementById('content3');//any place you want to display the color | |
const colors = document.querySelector('.colors'); //just a P to show the color HEX code | |
function createColor() { | |
const randl = Math.random().toString(16).substr(2, 6); | |
let color = `#${randl}`; | |
colors.innerHTML = color; | |
backg.style.backgroundColor = color; | |
} | |
createColor(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment