From eff440d1f26adec5f617c87ce4e3913ab0211726 Mon Sep 17 00:00:00 2001 From: Justin Oros Date: Wed, 20 May 2026 11:59:12 -0700 Subject: [PATCH] Shuffle question order on each new game so every run is different --- game.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/game.js b/game.js index 9ac8356..6921b9f 100644 --- a/game.js +++ b/game.js @@ -944,7 +944,15 @@ class Game { if (this.state.questions.length>0) { cb(); return; } fetch('./questions.json') .then(r=>r.json()) - .then(data=>{ this.state.questions=data.levels[0].questions; cb(); }) + .then(data=>{ + const qs = data.levels[0].questions; + for (let i = qs.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [qs[i], qs[j]] = [qs[j], qs[i]]; + } + this.state.questions = qs; + cb(); + }) .catch(()=>this.toast('❌ Could not load questions.json')); }