knuth-shuffle.js/example.js

14 lines
272 B
JavaScript
Raw Permalink Normal View History

2013-12-03 07:44:42 +00:00
(function () {
'use strict';
var shuffle = require('./').knuthShuffle
, a = [2,11,37,42]
, b
;
// The shuffle modifies the original array
// calling a.slice(0) creates a copy, which is assigned to b
b = shuffle(a.slice(0));
console.log(b);
}());