Generate a random hexadecimal color - Node.js Number

Node.js examples for Number:Random Number

Description

Generate a random hexadecimal color

Demo Code


/**//from ww w  .  ja va  2  s  .com
 * Generate a random hexadecimal color
 *
 * @return {string} Hexadecimal color
 */
export default function randomHexColor() {
  return '0x' + Math.floor( Math.random() * 16777215 ).toString( 16 );
}

Related Tutorials