I'm attempting to randomly assign background colors to table cells. I've created an array:
var randomColor = ["red","blue","green","mint","yellow","lightPurple"];
along with this function:
function setRandomColor(){
return randomColor[Math.floor(Math.random() * randomColor.length)];
}
You can view the code on jsfiddle here:
Upon running the program multiple times, you may notice that some td
cells end up with a white background color unexpectedly. This is strange since white is not included in the array of options.
I am unsure why this issue occurs, any insights would be greatly appreciated!
Thank you.