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 или более");
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 или более");
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 или более"); } Source: https://ru.stackoverflow.com/questions/516492/
All Articles