var shut = 3; var target = 0; if ((target==0)&&(shut >= 2) ){ if (shut == 3) { alert("равен 3"); return 3; } alert("равен 2 или более"); } 

why return does not return but continues the code and displays alert("равен 2 или более");

    1 answer 1

    Maybe because return returns the value of the function , not if ?
    Chrome generally fell with an error due to an unnecessary return .

    You can disable the display of the second alert via the else :

     var shut = 3; var target = 0; if ((target == 0) && (shut >= 2)) { if (shut == 3) alert("равен 3"); else alert("равен 2 или более"); } 

    • thanks helped - Freekazoid