0
could anybody help to explain the following code result? thanks
What is the output of this code? function x(y) { y++; y=y+2; ++y; y=y%3; return y; } document.write(x(3));
2 ответов
+ 3
Result is 1.
+ 1
replace y in the function with 3 and follow the code flow.
first 3 is incremented to 4 then 2 is added to it then it's incremented to 7 .
7%3 = 1 . because % operator returns the remainder of 7%3.