I could really use some help


#1



7. Next Dot 2


This code looks correct to me but can someone show me where I am making a mistake? This is the error it returns:

Oops, try again. When on the last slide, it looks like next arrow isn't wrapping back to the first dot. Look back at the instructions and check the code inside the if statement.


var main = function() {
    $('.dropdown-toggle').click(function() {
        $('.dropdown-menu').toggle();
    });
    
    $('.arrow-next').click(function() {
        var currentSlide = $('.active-slide');
        var nextSlide = currentSlide.next();
        currentSlide.fadeOut(600);
        nextSlide.fadeIn(600);
        
        if(nextSlide.length == 0) {
            nextSlide = $('.slide').first();
            nextDot = $('.dot').first();
        }
        
        var currentDot = $('.active-dot');
        var nextDot = $('.active-dot').next();
        
        currentDot.removeClass('active-dot');
        nextDot.addClass('active-dot');
    });
};



$(document).ready(main);


#2

Declare the variables before the if statement above them.


#3

@that1guy2
And what are you doing with

        currentSlide.fadeOut(600);
        nextSlide.fadeIn(600);

#4

Oh, those are for the slider animation.


#5

That isn't helping. Any other ideas?


#6

Please post a link to the exercise. Thanks.


#7

Here is the link to the exercise.

https://www.codecademy.com/courses/web-beginner-en-seyrq/0/7?content_from=make-an-interactive-website%3Ajquery-effects


#8

Leon pointed out two lines that are incomplete. Go back through the exercise that first creates those lines and correct them. The lines can be written after the if statement.


#9

Thanks a lot, that worked. It was a newbie error but I appreciate the help.


#10

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