0

Generate random hex color in JavaScript

JavaScript
var color = '#'+Math.floor(Math.random()*16777215).toString(16);

console.log(color);
RUN
JavaScript
var randomColor = Math.floor(Math.random()*16777215).toString(16);


console.log(randomColor);
RUN
add comment
Suggest a different solution or add another example