Why does == break my if else statement?


#1



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

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();
    };
    currentSlide.fadeOut(600).removeClass('active-slide');
    nextSlide.fadeIn(600).addClass('active-slide');
    
    
});
};

My code works perfectly with one = but fails with == in the line below:

nextSlide = $('.slide').first();
};

Is it simply incorrect syntax to use == or === for the if else statement?


#2

To assign values, a single equal sign is used. So, you would only use one equal sign like you are doing now. Here is a link in a jQuery excercise that might help you.:slight_smile:

https://www.codecademy.com/en/courses/web-beginner-en-GfjC6/0/3?curriculum_id=50a3fad8c7a770b5fd0007a1


#3

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