From 8da8d1e4aad9d65377d924bf57e5d787dc0e8bfe Mon Sep 17 00:00:00 2001
From: Travis CI
Randomizes the order of the values of an array, in place.
-Uses the Fisher-Yates algoritm to reorder the elements of the array, based on the Lodash implimentation
+Randomizes the order of the values of an array, returning a new array.
+Uses the Fisher-Yates algoritm to reorder the elements of the array, based on the Lodash implementation, but as a pure function.
const shuffle = ([...arr]) => {
let m = arr.length;
while (m) {
@@ -599,7 +599,9 @@ This method also works with strings.
}
return arr;
};
-// shuffle([1,2,3]) -> [2,3,1]
+// const foo = [1,2,3]
+// shuffle(foo) -> [2,3,1]
+// console.log(foo) -> [1,2,3]
Returns an array of elements that appear in both arrays.