If condition in Jquery

If condition in Jquery

if condition not working I don't understand why,


function slide(str){
        alert(str+'<<<str'); <<<< this Alert is working file and showing output [ next<<<str ]
        if(str=="next"){
            xp+=1462;
            alert("if"); <<<< str value is next but if condition is still not working and not showing this alrt; 
            if(xp>=5800){
                xp=0;
            $('imagecontainer-two').animate({left:xp},1000);
            }
        }else if(str=='back'){
           
        }
    }