 <p>what you want in your for loop is </p> <pre><code>for(k = deck.length - 1; k &gt;= 0; k--) </code></pre> <p>your indexing is off and it never enters the shuffle algorithm ( I didn't check the correctness of it FYI so you might bump into other problems)</p>