I need to create a JavaScript function that uses an array to hold the values: ["00", "33", "66", "99", "CC", "FF"]
. I then need to loop through the array and display all 216 web safe colors as hexadecimal values on my page. The code below is what I have so far but I am not sure about looping through to create the rest of the numbers.
function displayColors() {
var hex1;
var hex2;
var hex3;
var clr;
var steps = [
'00',
'33',
'66',
'99',
'cc',
'ff'
];
var arrLength = steps.length;
var counter = 1; // Make sure there are 216 colors displayed
for (var b = 0; b < arrLength; b++) {
hex1 = steps[b];
hex2 = steps[b];
hex3 = steps[b];
clr = hex1 + hex2 + hex3;
document.getElementById("display").innerHTML +=
"<div>" + counter + ": " + clr + "</div>";
counter++;
}
}