Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ddprrt
Created May 13, 2014 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddprrt/370eb62c8257dcf8eff3 to your computer and use it in GitHub Desktop.
Save ddprrt/370eb62c8257dcf8eff3 to your computer and use it in GitHub Desktop.
Rodney's comment shuffler
// http://stackoverflow.com/questions/6274339/how-can-i-shuffle-an-array-in-javascript
function shuffle(o){ //v1.0
for(var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
return o;
};
var foo = [].slice.call(document.querySelectorAll('.comment h4'));
shuffle(foo).slice(0, 2).map(function(item){ return item.textContent; })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment