vsupalov

Generate a random HTML grey value

October 29, 2011

Similar to theĀ randomColor function, but only for shades of grey:

function randomGrey() {
  var s = "#";
  var grey = randomRange(0,15).toString(16);

  while(s.length < 7) {
    s+=grey;
  }

  return s;
}

I really wish js had more built-in string methods.

Join the Mailing List

Subscribe to get weekly updates and my latest articles by email.

    (About the content, privacy, analytics and revocation).

    We won't send you spam. Unsubscribe at any time.

    Powered By ConvertKit