Validation issues with Flipboard Previous Dot 2


#1



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

Despite adding an active-dot to the previous Dot, I am still getting the error: "Oops, try again. Remember to add '.active-dot' to the previous dot." Any suggestions anyone?


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

$(document).ready(main);


#2

Hi Rowan,

Your previous slide if statement needs to come immediately after you create the variables, but before you modify the slides and dots.


#3

Thanks zystvan,

After posting I immediately realised this and got that satisfying green tick. Thanks for the reply!


#4

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