Previous Slide 2 Error : Code Won't Work


Hi everyone! I'm stuck in this exercise, as linked below. I've thoroughly looked through the code, and so far couldn't find what else I need to fix it, and would love some help please. I also only had to add lines 34 to 36 in this exercise as per instructions:

Inside the click event handler for '.arrow-prev', write an if statement to handle this case:
- After creating the variables currentSlide and prevSlide, write an if statement that checks if prevSlide.length == 0.
- If it is, set prevSlide equal to the last slide using $('.slide').last();
- Try it out! In the web page to the right, click the previous arrow and see what happens!

Error messages are as follows:
- Uncaught SyntaxError: Invalid or unexpected token
- Oops, try again. Remember to fade out the current slide and remove the 'active-slide' class.

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


Thank you very much!


Hi @samwiththej,

Take a close look at line 22 of your code :slight_smile:


Thank you so much! :blush:


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