var randomColor = '#'+ Math.floor(Math.random() * 19777215).toString(16);
var randomColor = Math.floor(Math.random()*16777215).toString(16);
// as rgb
var r = () => Math.random() * 256 >> 0;
var color = `rgb(${r()}, ${r()}, ${r()})`;
// as hexa color:
var randomColor = '#'+Math.floor(Math.random()*16777215).toString(16);
//generates a random color -> #56eec7
var randomColor = Math.floor(Math.random()*16777215).toString(16);
Create a snippet
Math.floor(Math.random()*16777215).toString(16);
function get_random_color()
{
var color = "";
for(var i = 0; i < 3; i++) {
var sub = Math.floor(Math.random() * 256).toString(16);
color += (sub.length == 1 ? "0" + sub : sub);
}
return "#" + color;
}
function get_rand_color()
{
var color = Math.floor(Math.random() * Math.pow(256, 3)).toString(16);
while(color.length < 6) {
color = "0" + color;
}
return "#" + color;
}
var rgb = [];
for(var i = 0; i < 3; i++)
rgb.push(Math.floor(Math.random() * 255));
myDiv.style.backgroundColor = 'rgb('+ rgb.join(',') +')';
var colors = ['red', 'green', 'blue', 'orange', 'yellow'];
myDiv.style.backgroundColor = colors[Math.floor(Math.random() * colors.length)];
const randomColor = `#${Math.floor(Math.random() * 0xffffff).toString(16)}`;
Hey do not forget to write the code with your hands :::