Q:

Executing wrong if statement in Chrome

When executing the following function, "The quantity is 1" and "Something went wrong" is logged. The quantity in the input is indeed 1, so why is the else statement executed when it fulfils the first if statement qty==1 ? This only happens in Chrome! Works fine in Firefox.
function updatePrices(IDs){
    var qty= parseInt($j("#qtyUpdateBox input").val());
    console.log("The qty is " + qty);//logs correctly

    if (qty==1){
        function sendRequest(i) {
            var optionSelectionArray = currentlySelectedAttributes(IDs[i]);
            simpleWithAttrPrice(optionSelectionArray, function(data) {
                //var vendor = IDs[i];
                var basePrice = parseFloat(roundDollar(data));
                $j('.details'+IDs[i]+ ' .priceBlock').empty();      
                $j('.details'+IDs[i]+ ' .priceBlock').append('<span>'+formatCurrency(basePrice,"$")+'</span>');
                $j('.details'+IDs[i]+ ' .priceBlock').append('<input type="hidden" name="customPrice" value="' + basePrice + '"/>');
            });
        }//end sendRequest

        for(i=0; i<IDs.length; i++)
        {   
            sendRequest(i);
        }

    }//end if
    else{
        //ajax call to obtain tier prices for each vendor id
        function sendRequest(i,qty,product_id){
            var vendor = IDs[i]; 
            $j.ajax({
                    type: "POST",
                    url: "/ajax_calls/updatePrices.php",
                    data: { 'vendorID': vendor, 'product_id': product_id}
                    }).done(function(data) {
                        //console.log('The data is ' + data);
                        //CAITLIN below may need to be parsed in the php script
                            var data= JSON.parse(data);

                            var optionSelectionArray = currentlySelectedAttributes(data.vendor_id);
                            simpleWithAttrPrice(optionSelectionArray, function(price) {
                                var basePrice = roundDollar(parseFloat(price));
                                var pricexQty= basePrice * qty;

                                if (qty < data.tier2_range_start){
                                    var totalPrice = basePrice*qty; 
                                }
                                else if (qty >= data.tier2_range_start && qty < data.tier3_range_start){
                                    var discountPercent = data.tier2_discount;
                                    var discount = pricexQty * data.tier2_discount / 100;
                                    var totalPrice = pricexQty - discount;
                                    var unitPrice = totalPrice/qty;
                                }
                                else if (qty >= data.tier3_range_start && qty < data.tier4_range_start){
                                    var discountPercent = data.tier3_discount;
                                    var discount = pricexQty * data.tier3_discount / 100;
                                    var totalPrice = pricexQty - discount;
                                    var unitPrice = totalPrice/qty;
                                }
                                else if (qty >= data.tier4_range_start && qty < data.tier5_range_start){
                                    var discountPercent = data.tier4_discount;
                                    var discount = pricexQty * data.tier4_discount / 100;
                                    var totalPrice = pricexQty - discount;
                                    var unitPrice = totalPrice/qty;
                                }
                                else if (qty >= data.tier5_range_start){
                                    var discountPercent = data.tier5_discount;
                                    var discount = pricexQty * data.tier5_discount / 100;
                                    var totalPrice = pricexQty - discount;
                                    var unitPrice = totalPrice/qty; 
                                }
                                else{
                                    console.log('Something went wrong');
                                }

                                unitPrice = roundDollar(unitPrice);

                                $j('.details'+data.vendor_id+ ' .priceBlock').empty();//update product price in DOM
                                if (discountPercent)
                                    $j('.details'+data.vendor_id+ ' .priceBlock').append('<h5 style="color:gold">You will save '+discountPercent+'% !</h5>');
                                $j('.details'+data.vendor_id+ ' .priceBlock').append('<span>Unit Price: '+formatCurrency(unitPrice,"$")+'</span> / ');
                                $j('.details'+data.vendor_id+ ' .priceBlock').append('<span>Total Price: '+formatCurrency(unitPrice*qty,"$")+'</span>');
                                $j('.details'+data.vendor_id+ ' .priceBlock').append('<input type="hidden" name="customPrice" value="' + unitPrice + '"/>');
                        });//end callback function

                    });//end done function
                }//end function sendRequest

        for(i=0; i<IDs.length; i++)
        {   
            sendRequest(i,qty,product_id);
        }
    }//end else

}//end function 

A:

I think it has to do with method hoisting. it causes the second declaration to override the first one irrespective of the if statement.
A fix you can try is to change the method declaration style to var sendRequest = function(){...} from function sendRequest() {...}
The problem can be demonstrated using this demo
One possible solution is demonstrated here
Note: For the reason why it is happening read about hoisting in javascript

