Skip to content

Commit

Permalink
feat(shuffle-array): check array type on parameter level
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusfg7 committed Feb 13, 2024
1 parent 28fc983 commit b2ae59d
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/lib/shuffleArray.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
export function shuffleArray<T>(array: T) {
if (!Array.isArray(array)) throw new Error('"array" is not an array')

export function shuffleArray<T>(array: T[]) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1))
;[array[i], array[j]] = [array[j], array[i]]
Expand Down

0 comments on commit b2ae59d

Please sign in to comment.