Answered>Order 4327

  1. Make a file data/colourList.js , which creates a global array called colourList, containing a list of 5 colours (e.g. “red”, “blue”, etc).
  2. In your week5a.js file, make 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 element’s background colour.
  3. In addition to the aforementioned button, make 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 BODY’s background colour will specifically change to the button’s colour.
  4. Further to the last step, colour the background of each button to be the same as the button’s intended colour. E.g. if a button says “blue”, then the background colour of that button should be blue.
 
"Not answered?"
Get the Answer