Created
July 11, 2013 19:18
-
-
Save wfendler/5978388 to your computer and use it in GitHub Desktop.
Building a memory/matching game. I want to start with 6 divs, clone them, and randomize the order. At this point I have an array with 12 items. Is this correct so far?
I've found some functions to randomize the order of an array. That shouldn't be a problem. Once I have that, is it fastest to do a for loop and .append() to the page? Or should I …
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
this.$initialCardCollection.length = $('.js-memory-card'); | |
this.fullCardCollection = []; | |
// this.$initialCardCollection.length has the original divs on the page that i'll clone. | |
for ( var i = 0; i < this.$initialCardCollection.length; i++ ) { | |
var $thisCard = $(this.$initialCardCollection[i]); | |
this.fullCardCollection.push( $thisCard ); | |
this.fullCardCollection.push( $thisCard.clone() ); | |
} | |
Author
wfendler
commented
Jul 11, 2013
I put a for loop in your for loop so you can loop while you loop
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment