I watched a codecademy video and have been unable to randomize my color array. The colors are not random. I am not sure what I am doing wrong.
function getRandomColor() {
var color;
var colorArray = [
"#FF6633",
"#FFB399",
"#FF33FF",
"#FFFF99",
"#00B3E6",
"#E6B333",
"#3366E6",
"#999966",
"#809980",
"#E6FF80",
"#1AFF33",
"#999933",
"#FF3380",
"#CCCC00",
"#66E64D",
"#4D80CC",
"#FF4D4D",
"#99E6E6",
"#6666FF"
];
for (var i = 0; i < colorArray; i++) {
color = colorArray[Math.floor(Math.random() * colorArray.length)];
}
return color;
}
Aucun commentaire:
Enregistrer un commentaire