This is my first question on here, please be gentle. I just noticed in Safari, Chrome and Firefox's console, the color values from the following script always return an RGB value instead of a HEX value. Not that it's preventing the code from working or anything, I'm just curious to know why wouldn't the console return the HEX value that was sent? Does Javascript always translate color values to RGB? Is it a first class citizen over other paradigms?
function randomHEX() {
var HEXvalues = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "A", "B", "C", "D", "E", "F"];
var newHEX = "#";
for (i = 0; i < 6; i++) {
var nextIndex = Math.floor(Math.random() * HEXvalues.length); // grab a random value from the array
newHEX += HEXvalues[nextIndex]; // increment values to newHEX
}
document.querySelector("#hexName").textContent = newHEX; // use newHEX to fill text of ID hexName
document.querySelector(".container").style.backgroundColor = newHEX; // use newHEX to change background color of box
}
Any information would be appreciated.
Many thanks.
PS
Thank you to those who responded. My question though was why RGB? Why not default to the HEX number it received? Why does Javascript translate a HEX value to an RGB value with .style.backgroundColor?
Again, many thanks.