Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery var returning object [closed]

I have a variable called loopNum which returns as an object in console. The other variables return as expected. Can anyone explain why this is happening? Thanks

Script

    // stores how many carousels there are
    var carouselNum = $('.carousella').length;

    // stores the product of number of carousels times the increment value
    var loopNum = $((carouselNum - 2) * -183);

    console.log('loopNum = ' + loopNum);
    console.log('carouselNum = ' + carouselNum);

Console

loopNum = [object Object]
like image 561
Clinton Green Avatar asked Feb 23 '26 01:02

Clinton Green


1 Answers

Don't wrap the carouselNum variable into a jQuery wrapper $() after assigning it. Try this:

var carouselNum = $('.carousella').length;

// stores the product of number of carousels times the increment value
var loopNum = (carouselNum - 2) * -183;
like image 156
mattytommo Avatar answered Feb 25 '26 14:02

mattytommo