How to fix jshint (W083)?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
15 views
Please tell me how to solve this problem.
I need to declare the timer outside the loop, but this causes the error.
let timerSearch = 0; for (let i = 0; i < points.length; i++) { setTimeout(() => { console.log("i"); }, timerSearch += 500); }


error: Functions declared within loops referencing an outer scope variable may lead to confusion semantics. (W083)
by | 15 views

2 Answers

0 like 0 dislike
After 500 you forgot to close the bracket.
timerSearch += 500);
by
0 like 0 dislike
Something like (not tested if it works jshint):

delayedSearch function(pointIndex) { setTimeout(() => { console.log(pointIndex); }, pointIndex * 500); } for (let i = 0; i < points.length; i++) { delayedSearch(i); }
by

Related questions

0 like 0 dislike
2 answers
110,608 questions
257,187 answers
0 comments
40,796 users