From 4191c02d62ca847e58c1196b58995531e9ce0f83 Mon Sep 17 00:00:00 2001 From: Keshav2567 <70498256+Keshav2567@users.noreply.github.com> Date: Mon, 5 Jul 2021 18:08:26 +0530 Subject: [PATCH] Fixed endless error Handled the error if user input is undefined or just an empty string (which causes an endless error) --- random-choice-picker/script.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/random-choice-picker/script.js b/random-choice-picker/script.js index 443f3ed..3fddcc6 100644 --- a/random-choice-picker/script.js +++ b/random-choice-picker/script.js @@ -33,12 +33,14 @@ function randomSelect() { const interval = setInterval(() => { const randomTag = pickRandomTag() - + + if (randomTag !== undefined) { highlightTag(randomTag) setTimeout(() => { unHighlightTag(randomTag) }, 100) + } }, 100); setTimeout(() => { @@ -64,4 +66,4 @@ function highlightTag(tag) { function unHighlightTag(tag) { tag.classList.remove('highlight') -} \ No newline at end of file +}