7/12 Where's the bug?


#1

I seem to be stuck attempting to move my dot back to the first dot. I have tried triple checking my code in the if statement as the "Oops" message suggests but it appears to be the same.

I even tried copying and pasting the code from the hint to no avail. It still says that the dot is not returning to the first.

var main = function () {
$('.dropdown-toggle').click(function() {
$('.dropdown-menu').toggle();
});

$('.arrow-next').click(function() {
    var currentSlide = $('.active-slide');
    var nextSlide = currentSlide.next();

    if(nextSlide.length === 0) {
       nextSlide = $('.slide').first();
       nextDot = $('.dot').first();
    };

    currentSlide.fadeOut(600).removeClass('active-slide');
    nextSlide.fadeIn(600).addClass('active-slide');  

    var currentDot = $('.active-dot');
    var nextDot = currentDot.next();

    currentDot.removeClass('active-dot');
    nextDot.addClass('active-dot');
});

};

$(document).ready(main);


#2

uhh stupid me! the vars have to be at the top with the other vars. DUH!


#3

I got the same error, and the var's are at the top :smile:


#4

same error. I don't know how to fix it


#5

var currentDot = $('.active-dot');
var currentSlide = $('.active-slide');

Remove the class selector ( the dot before active) it gets the job done, I saw it in another help request


#6

still not working. :frowning:


#7

got it in the meantime. the problem was that I didn't remove the class active dot from currentDot and add it to the nextDot


#8

it's very tricky with these dots. I encounter the same issues in the next exercises..


#9

did you find the problem?


#10
  1. You are using nextDot before you have even declared it. Those two lines ( var currentDot and var nextDot) need to be placed before the if statement (below the line var nextSlide) not after it.

  2. Use $() to remove and add classes, i.e $(currentDot).removeClass and $(nextDot).addClass


#11

MAde the same mistake


#12

make sure your if statement is directly after your variable declarations