Skip to content

Instantly share code, notes, and snippets.

@daffodilistic
Created November 25, 2022 03:06
Show Gist options
  • Save daffodilistic/0d260f46aa7184ae92d867bda7f7ad38 to your computer and use it in GitHub Desktop.
Save daffodilistic/0d260f46aa7184ae92d867bda7f7ad38 to your computer and use it in GitHub Desktop.
Lazy JavaScript Random Color
function getRandomColor(excludeHex) {
let rgb = [ 255, 255, 255 ];
return `${excludeHex ? '' : '#'}${rgb.map(x => Math.floor(Math.random() * 255 + 1).toString(16)).join("")}`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment