Skip to content

Instantly share code, notes, and snippets.

@amadden80
Created July 29, 2015 14:53
Show Gist options
  • Select an option

  • Save amadden80/7dd7a725958354fe0f16 to your computer and use it in GitHub Desktop.

Select an option

Save amadden80/7dd7a725958354fe0f16 to your computer and use it in GitHub Desktop.
// 1. Write a function that changes the background color of a website
function changeBackground(){
// 2. Write an array of color strings
var colors = ['red', 'green', 'orange', 'purple', 'blue'];
// 3. Have your color change function randomly select one of the colors from that array
var colorChoice = colors[ Math.floor( Math.random() * colors.length ) ];
document.body.style.backgroundColor = colorChoice;
}
setInterval( changeBackground, 100 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment