Last active
August 29, 2015 14:00
-
-
Save L3viathan/11357145 to your computer and use it in GitHub Desktop.
daily wurst fun fact, js edition (v1)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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