Question: Create a file data/colourList.js , which creates a global array called colourList, containing a list of 5 colours (e.g. red, blue, etc). In your week5a.js
Create a file data/colourList.js , which creates a global array called colourList, containing a list of 5 colours (e.g. "red", "blue", etc).
In your week5a.js file, create a button Randomise Colour which calls a function randomiseBackgroundColour(). This function, when executed, will select a random colour from our colourList array, and change the document BODY elements background colour.
In addition to the aforementioned button, create a vertical list of buttons for each colour in the colourList. Each buttons text should be the colour name. When that button is clicked, the document BODYs background colour will specifically change to the buttons colour.
Further to the last step, colour the background of each button to be the same as the buttons intended colour. E.g. if a button says "blue", then the background colour of that button should be blue.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
