From the course: ESLint: Checking for Syntax and Logic Errors
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Identifying problems in loops and conditionals
From the course: ESLint: Checking for Syntax and Logic Errors
Identifying problems in loops and conditionals
- [Instructor] The loops and conditionals section of index.js, starting on line 15, contains a couple of issues I want ESLint to flag. There's a for loop starting on line 19. As far as my editor is concerned, everything's fine there, but I can use ESLint to check if the direction of my iterator change makes sense given my condition. To do that, I use the for direction rule. Over in my ESLint rc file, I'll add for direction with the value of error. So that's in the rules section, and for dash direction, and error. Saving that, I'm going to go back to index.js and I have a new error flagged. So, if I move the pointer over that that tip text is going to point out that the update clause moved the variable in the wrong direction. So, my code starts at 10, and it checks for a value greater than zero, and increasing I after each loop. That creates an infinite loop, because I will never satisfy that ending condition. I'm…
Contents
-
-
-
Understanding ESLint error rule types1m 39s
-
(Locked)
Flagging issues in functions3m 4s
-
(Locked)
Identifying problems in loops and conditionals3m 12s
-
(Locked)
Eliminating unfinished code4m 44s
-
(Locked)
Ensuring accurate values3m 39s
-
(Locked)
Calling out general logic errors4m 28s
-
(Locked)
Challenge55s
-
(Locked)
Solution6m 33s
-
-