From the course: Code Clinic: JavaScript

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

Navigating through solutions

Navigating through solutions - JavaScript Tutorial

From the course: Code Clinic: JavaScript

Start my 1-month free trial

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…

Contents