Skip to content

Instantly share code, notes, and snippets.

@L3viathan
Last active August 29, 2015 14:00
Show Gist options
  • Save L3viathan/11357145 to your computer and use it in GitHub Desktop.
Save L3viathan/11357145 to your computer and use it in GitHub Desktop.
daily wurst fun fact, js edition (v1)
function pickRandomProperty(obj) {
// from http://stackoverflow.com/questions/2532218/pick-random-property-from-a-javascript-object
var result;
var count = 0;
for (var prop in obj)
if (Math.random() < 1/++count)
result = prop;
return result;
}
$.when(API.statData()).done(function(data) {
var player = pickRandomProperty(data)
var objective = pickRandomProperty(data[player]);
var progress = data[player][objective];
console.log(player + " has so much progress: " + progress + " in objective " + objective.slice(5));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment