shuffle http

This commit is contained in:
Bel LaPointe
2023-04-07 14:01:52 -06:00
parent 0fd0981a39
commit 64e992c6b6

View File

@@ -37,6 +37,18 @@
map((key) => [ map((key) => [
[key, knowledgebase[key]] [key, knowledgebase[key]]
]) ])
function shuffle(array) {
let currentIndex = array.length, randomIndex;
while (currentIndex != 0) {
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex--;
[array[currentIndex], array[randomIndex]] = [
array[randomIndex], array[currentIndex]];
}
return array;
}
shuffle(knowledgebase)
console.log(0, knowledgebase) console.log(0, knowledgebase)
function passQuestion(form) { function passQuestion(form) {