the array shuffling example inserted undefined elements in into arrays of length 0 or 1. a length check was needed