Skip to content

Instantly share code, notes, and snippets.

@illepic
Last active October 22, 2016 18:39
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 illepic/2e69feb8b57b700239cc3de6d600ca1c to your computer and use it in GitHub Desktop.
Save illepic/2e69feb8b57b700239cc3de6d600ca1c to your computer and use it in GitHub Desktop.
function shuffle(shufflearray) {
var i = shufflearray.length;
var j;
var temp;
while(i-- > 0) {
j = Math.floor(Math.random() * (i + 1));
temp = shufflearray[j];
shufflearray[j] = shufflearray[i];
shufflearray[i] = temp;
}
return shufflearray;
}
$(function() {
var cardsubset = shuffle(cardarray).slice(0,10);
var $container = $('<div>');
cardsubset.forEach(function(element, index, array) {
var $img = $('<img>').attr('src', element.card);
$container.append($img);
});
$('.card-images').append($container);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment