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

15th Mar 2022, 1:27 AM
Evgeny Sergeev
Evgeny Sergeev - avatar
2 Antworten
+ 6
Evgeny Sergeev Output is 1 because function is not calling. if you call function before printing x then output would be x = 5
15th Mar 2022, 3:22 AM
A͢J
A͢J - avatar
+ 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
15th Mar 2022, 1:48 AM
HungryTradie
HungryTradie - avatar