+ 2
Could someone explain me how this code works line to line? Thanks.
for(var i=1;i<4;i++){ i=f(i); } function f(x){ return x+2; }
4 ответов
+ 2
FUNCTION SHOULD BE DECLARED FIRST BEFORE YOU CALL IT.
THIS CODE WILL GENERATE ERROR.
+ 2
IF IT IS DECLARED FIRST THAN
YOUR CODE WILL LOOP FOUR TIME .
EVERY TIME YOUR PROGRAM LOOP , IT WILL CALL FUNCTION f WHICH WILL INCREMENT CURRENT I VALUE AND STORE IT IN I.
0
ok, but it will run at least once?
0
NO. FOR GOD'S SAKE.