Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

generate random color

function getRandomColor() {
    const availableCharacters = '0123456789ABCDEF';
    const availableCharacterLength = availableCharacters.length;

    let color = '#';

    for (let i = 0; i < 6; i++) {
      color += availableCharacters[Math.floor(Math.random() * availableCharacterLength)];
    }

    return color;
}

console.log(getRandomColor()); // #3BB46D
Source by javascriptf1.com #
 
PREVIOUS NEXT
Tagged: #generate #random #color
ADD COMMENT
Topic
Name
1+9 =