Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Javascript Recursion shuffle card

function shuffleCards(topHalf, bottomHalf,results = []) {
    if(topHalf.length===0&&bottomHalf.length===0)return results;
    if (topHalf.length!==0) {
    results.push(topHalf[0])
    } 
    if (bottomHalf.length!==0) {
      results.push(bottomHalf[0])
    }
    return shuffleCards(topHalf.slice(1), bottomHalf.slice(1),results);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Javascript #Recursion #shuffle #card
ADD COMMENT
Topic
Name
9+2 =