Skip to content

Commit ea1ff0a

Browse files
authored
Added Shuffle Array function
1 parent 286578b commit ea1ff0a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

public/data/javascript.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,21 @@
2727
],
2828
"tags": ["javascript", "array", "flatten", "utility"],
2929
"author": "technoph1le"
30-
}
30+
},
31+
{
32+
"title": "Shuffle Array",
33+
"description": "Shuffles an Array.",
34+
"code": [
35+
"function shuffleArray(array) {",
36+
" for (let i = array.length - 1; i >= 0; i--) {",
37+
" const j = Math.floor(Math.random() * (i + 1));",
38+
" [array[i], array[j]] = [array[j], array[i]];",
39+
" }",
40+
"}"
41+
],
42+
"tags": ["javascript", "array", "shuffle", "utility"],
43+
"author": "loxt-nixo"
44+
},
3145
]
3246
},
3347
{

0 commit comments

Comments
 (0)