Updated Script.js

fixed error : cannot read properties of undefined (reading 'classlist' )
cause : when pressing enter without entering any value in the input field
fix : 1. cleared interval 'interval' for undefined value of 'randomTag' variable and returned
pull/154/head
abhishekdobhal8 3 years ago committed by GitHub
parent 236f68461b
commit 145c3138db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -34,13 +34,14 @@ function randomSelect() {
const interval = setInterval(() => {
const randomTag = pickRandomTag()
if (randomTag !== undefined) {
highlightTag(randomTag)
setTimeout(() => {
unHighlightTag(randomTag)
}, 100)
if (randomTag == undefined) {
clearInterval(interval);
return;
}
randomTag.classList.add("highlight");
setTimeout(() => {
randomTag.classList.remove("highlight");
}, 100);
}, 100);
setTimeout(() => {
@ -48,7 +49,7 @@ function randomSelect() {
setTimeout(() => {
const randomTag = pickRandomTag()
if (randomTag == undefined) return;
highlightTag(randomTag)
}, 100)

Loading…
Cancel
Save