i am having problem in getting the value of the variable. In the each query loop i am getting the correct calculated value but when i try to get the value outside the each loop then it shows the value as 0 Here is the Code: Updated Code
// Discounts Calculations
        var item_discounts_current = 0;
        $(this).nextUntil("#item-extras-discounts").find('.item-current-discounts :selected').each(function(item_discounts_current) {
            var item_discounts_type = parseFloat( $(this).attr('data-dtype') );
            if ( item_discounts_type == 1 ) {
                item_discounts_current += parseFloat( $(this).attr('data-dvalue') ) + item_discounts_current;
            }
            else {
                var percentage_val = parseFloat( $(this).attr('data-dvalue') ) / 100;
                var new_item_discount_value = item_total_price_current * percentage_val;
                item_discounts_current += item_discounts_current + new_item_discount_value;
            }
            // This is showing calculated value
            console.log(item_discounts_current);
        });
        // This is showing 0 value
        console.log(item_discounts_current);
 
     
    