Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

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;
}
Comment

random color generator

function randomColor(e){return '#'+Math.round(Math.random()*0xffffff).toString(16);}

randomColor(/*idk*/)
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript removing smallest number in array 
Javascript :: fetch request to GraphQL 
Javascript :: js mouse enter 
Javascript :: how to filter an array to only get numbers 
Javascript :: how to call create react app 
Javascript :: codewars js Find the first non-consecutive number 
Javascript :: how to detect a button click in javascript 
Javascript :: moment get time am pm 
Javascript :: end code nodejs 
Javascript :: get device type using javascript 
Javascript :: write files in node js 
Javascript :: set dropdown value using jquery 
Javascript :: react get input value on button click functional component 
Javascript :: find the words separated by whitespace in a string javascript 
Javascript :: web3 check if contract 
Javascript :: pass js var to laravel route 
Javascript :: add font awesome to vue 
Javascript :: mysql get json value by key 
Javascript :: js rectangle collision 
Javascript :: check if an HTML element has any children 
Javascript :: switch browser to fullscreen 
Javascript :: NotYetImplemented ng2-chart angular 2 
Javascript :: p5 js cdn 
Javascript :: javascript find all href with same value 
Javascript :: javascript group by sum array reduce 
Javascript :: array remove element js 
Javascript :: adonisjs livereload 
Javascript :: ryan dahl 
Javascript :: how to add an element to the last position of an array in javascript 
Javascript :: electron app to exe 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =