From 8c45b2d48d1263d972c705f5011540127a4b6ede Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 5 Oct 2020 19:14:22 +0100 Subject: [PATCH] removed the posibility of duplicate quotes --- public/js/script.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/public/js/script.js b/public/js/script.js index a52e2e0e1..24786fa9e 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -529,8 +529,12 @@ function initWords() { group = Math.floor(Math.random() * quotes.groups.length); } - randomQuote = quotes.groups[group][Math.floor(Math.random() * quotes.groups[group].length)]; - let w = randomQuote.text.trim().split(" "); + rq = quotes.groups[group][Math.floor(Math.random() * quotes.groups[group].length)]; + if (randomQuote != null && rq.id === randomQuote.id) { + rq = quotes.groups[group][Math.floor(Math.random() * quotes.groups[group].length)]; + } + randomQuote = rq; + let w = rq.text.trim().split(" "); for (let i = 0; i < w.length; i++) { wordsList.push(w[i]); }