File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -15,8 +15,7 @@ const createTags = (input) => {
1515 } ) ;
1616} ;
1717
18- const pickRandomTag = ( ) => {
19- const tags = document . querySelectorAll ( ".tag" ) ;
18+ const pickRandomTag = ( tags ) => {
2019 return tags [ Math . floor ( Math . random ( ) * tags . length ) ] ;
2120} ;
2221
@@ -25,9 +24,10 @@ const highlightTag = (tag) => tag.classList.add("highlight");
2524const unHighlightTag = ( tag ) => tag . classList . remove ( "highlight" ) ;
2625
2726const randomSelect = ( ) => {
27+ const tags = document . querySelectorAll ( ".tag" ) ;
2828 const times = 30 ;
2929 const interval = setInterval ( ( ) => {
30- const randomTag = pickRandomTag ( ) ;
30+ const randomTag = pickRandomTag ( tags ) ;
3131 highlightTag ( randomTag ) ;
3232 setTimeout ( ( ) => {
3333 unHighlightTag ( randomTag ) ;
@@ -37,7 +37,7 @@ const randomSelect = () => {
3737 setTimeout ( ( ) => {
3838 clearInterval ( interval ) ;
3939 setTimeout ( ( ) => {
40- const randomTag = pickRandomTag ( ) ;
40+ const randomTag = pickRandomTag ( tags ) ;
4141 highlightTag ( randomTag ) ;
4242 } , 100 ) ;
4343 } , times * 100 ) ;
You can’t perform that action at this time.
0 commit comments