Skip to content

Instantly share code, notes, and snippets.

function getBackgroundColor (user) {  
  var m = user.picture.match(/avatar\/(\w+|$)/);
  if (m && m[1]) {
    return '#' + m[1].substring(0,6);
  }
}

Bonne idée ! Quelques remarques cependant :