COLOR CHANGE
In this Project, your web page background color will be changed randomly when you clicked button on the page.
You have a colors array. Use this colors array to select random color each time.
Create a variable button1 to select button.
Assign button1 clicking expression to an empty arrow function. This function will run whenever the button is clicked.
Inside this function ; Create variable colorIndex and for each run create random number for it.
Change body background color (inside) at the end of the function. Use colors array and index number to select a color.
Refresh your page and see your page background color is changing.
Now create a second button near others. This button will change color according to hex code. Example โ#ff0055โ.
Create an array consist of numbers and letter that used for hex code.
Create a variable button2 to select second button. Assign button2 clicking expression to an empty arrow function. This function will run whenever the button is clicked.
Inside this function ; make same things you did before. And assign body background color by clicking this button.
- CHALLENGE Everytime you run the color change functions, write your color code or name to the DOM.
Good luck!