0
Whatâs the logic here #2
What is the output of this code? var x = 1; vary = 4; function func(){ while (y > O) { Ă++; y--; } } document.write(x); Output: 1 To me itâs 1+1+1+1 Because loop goes 3 times Maybe because itâs x++ not ++x making x stay the same at: 1
2 Answers
+ 6
Evgeny Sergeev
Output is 1 because function is not calling.
if you call function before printing x then output would be x = 5
+ 3
G'day Evgeny Sergeev have you found the SoloLearn FAQ? I think there is a link in this post:
Your code creates a function called func() but doesn't call that function.
{Edit: it would be much easier if you linked a "code bit" instead of copy+paste in words. you can also read this post to maximize good answers. Lastly, if your question is answered would you please edit your original post to start with [Solved] thanks!}
https://www.sololearn.com/discuss/1316935/?ref=app
https://www.sololearn.com/discuss/333866/?ref=app