Last active
April 1, 2024 19:56
-
-
Save nathanpuls/5fd13a50b496f6552c05bc110ca39f6f to your computer and use it in GitHub Desktop.
function.txt
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
function changeBackgroundColor() { | |
// Generate random values for red, green, and blue components | |
const red = Math.floor(Math.random() * 256); | |
const green = Math.floor(Math.random() * 256); | |
const blue = Math.floor(Math.random() * 256); | |
// Construct a CSS color string | |
const randomColor = `rgb(${red}, ${green}, ${blue})`; | |
// Apply the random color to the background | |
document.body.style.backgroundColor = randomColor; | |
} | |
// Call the function to change the background color | |
changeBackgroundColor(); | |
console.log("bg color"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment