From the course: Code Clinic: JavaScript
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Navigating through solutions - JavaScript Tutorial
From the course: Code Clinic: JavaScript
Navigating through solutions
- [Instructor] All right, so the last thing we need to do is make sure that these buttons allow us to advance and move back through our solutions. So to do that I'm going to move right here and do some ducument queryselector queries. We'll do the Previous button first. And we will add an event listener. Of course we're gonna be looking for a click. And then call a function that will pass along an event. We'll decrement the current solution and then if the solution is less than one, so if we click and it's already at the first position we will reset it so that it's at the index of the last position. Minus one because arrays are zero indexed, so this means the last one. And it looks like I need a parentheses right there. All right, so then we will need to clear the board with the clear the board function we created earlier and then we will need to actually load up the new board. And then finally we'll display the current solution here. All right, so let's see if that works. If we click…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Intro: Eight queens1m 45s
-
(Locked)
Solution overview1m 31s
-
(Locked)
Preparing the board6m 46s
-
(Locked)
Setting up the board4m 17s
-
(Locked)
Computing solutions3m 56s
-
(Locked)
Finishing calculations7m 23s
-
(Locked)
Storing board solutions4m 1s
-
(Locked)
Display solutions4m 7s
-
(Locked)
Navigating through solutions3m 32s
-
(Locked)
-
-
-