8. Previous Slide 1. - Keep getting error? Code works fine?


8. Previous Slide 1.

So I can't figure out what is wrong here. It seems to me that my code is fine, yet it keeps giving me this message: "Oops, try again. It looks like previous arrow isn't moving back to the previous slide. Look back at the instructions and check the $('.arrow-prev').click() event handler".

Now I have triple checked all capitals, punctuation etc. in the event handler, but I can't find anything wrong with it. I have also tried to copying the code given in the Hint section, but that gave me the same error. Any insights?

The code does seem to function, by the way. Clicking the prev arrow results in a white screen (which is logical).

var main = function(){
        var currentSlide = $('.active-slide');
        var nextSlide = currentSlide.next();
        var currentDot = $('.active-dot');
        var nextDot = currentDot.next();
        if(nextSlide.length == 0){
            nextSlide = $('.slide').first();
            nextDot = $('.dot').first();
  $('.arrow-prev').click(function() {
    var currentSlide = $('.active-slide');
    var prevSlide = currentSlide.prev();




So apparently, the issue was that the instructions said to use 'prev()', whereas I should've used 'previous()'. Sigh. Well it's fixed now. :slight_smile:


@marankew That's incorrect - it looks like you got passed by breaking the code checker. There's no previous() function, prev() is correct. The actual problem is with your first two uses of addClass() and removeClass().


Ah, I see now, thank you! I was too focussed on the prev-click event, as that was what the error mentioned.

Just wondering, why does the IDE color previous() red (like it does with next() ) and not prev(), as that is the reason I first figured that it might be the issue.



why does the IDE color previous() red (like it does with next() ) and not prev()

I really don't know how the syntax highlighter works, but the color it makes something doesn't actually give any indication of whether or not a certain function exists, so you can safely ignore it most of the time - it's just there to make scanning your code easier and to spot obvious stuff like a missing quote at the end of a string :slight_smile:


This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.