Javascript

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>

This is some code i have. It is set up so when I click a button the background changes. I want to make it so it changes the color on It’s own. Current code below( this doesnt show the button that activates it, It works )


function funcToRun() {
    var randomNumber = Math.random();
    if (randomNumber <= 0.10) {
        document.body.style.background = 'red';
    }
    else if (randomNumber <= 0.20) {
        document.body.style.background = 'blue';
    }
    else if (randomNumber <= 0.30) {
        document.body.style.background = 'lime';
    }
    else if (randomNumber <= 0.40) {
        document.body.style.background = 'fuchsia';
    }
    else if (randomNumber <= 0.50) {
        document.body.style.background = 'pink';
    }
    else if (randomNumber <= 0.60) {
        document.body.style.background = 'magenta';
    }
    else if (randomNumber <= 0.70) {
        document.body.style.background = 'orange';
    }
    else if (randomNumber <= 0.80) {
        document.body.style.background = 'aqua';
    }
    else if (randomNumber <= 0.90) {
        document.body.style.background = 'violet';
    }
    else {
        document.body.style.background = 'yellow';
    }
}


2 posts were merged into an existing topic: Javascript