title: Pick random property from a Javascript object
body: <p>Suppose you have a Javascript object like {'cat':'meow','dog':'woof' ...}
  Is there a more concise way to pick a random property from the object than this long winded way I came up with:</p>
  
  <pre><code>function pickRandomProperty(obj) {
      var prop, len = 0, randomPos, pos = 0;
      for (prop in obj) {
          if (obj.hasOwnProperty(prop)) {
              len += 1;
          }
      }
      randomPos = Math.floor(Math.random() * len);
      for (prop in obj) {
          if (obj.hasOwnProperty(prop)) {
              if (pos === randomPos) {
                  return prop;
              }
              pos += 1;
          }
      }       
  }
  </code></pre>