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 :: js get node index 
Javascript :: html escape function javascript 
Javascript :: react i18n outside component 
Javascript :: countdown timer with moment js 
Javascript :: puppeteer set download path 
Javascript :: js add array to array 
Javascript :: js object clear 
Javascript :: disable button js 
Javascript :: sum values in array javascript 
Javascript :: AsyncStorage.getItem undefined is not an object 
Javascript :: text overflow ellipsis two lines react native 
Javascript :: console log return from async 
Javascript :: javascript math methods 
Javascript :: get current url react router 
Javascript :: using html forms to define javascript variables 
Javascript :: javascript count character in string 
Javascript :: linux cli format json 
Javascript :: jquery preload images 
Javascript :: convert an object to an array 
Javascript :: replace each string by another string javascript 
Javascript :: moment js get french time 20:00:00 
Javascript :: add class in element on scroll 
Javascript :: passportjs serializeuser 
Javascript :: vue js tutorial 
Javascript :: convert a string to number in javascript 
Javascript :: remove duplicates from array in javascript 
Javascript :: angular go to external url with blank target 
Javascript :: mongodb.connect is not a function 
Javascript :: react does not send the cookie automatically 
Javascript :: regex for a, e, i , o , u 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =