0
Confusing Increment (JS)
Every time I increase the number of increment the digits in the ouput decreases.one x++ gives 5 output, 2 x++ gives 3, 3 gives 1. https://code.sololearn.com/WJKCn8FhSJCY/?ref=app
3 Respuestas
+ 2
hey man see and understand the flow of code. first it is printing orginal value of x (1) and then it does increment by two postfix that means (3) then it checks condition wheather it is greater than 5 it means noo then it again goes up and increment two timess and now it retains 5 that means x = 5 now it again goes up and increment and now it becomes 7 it means it is greater than 5 so it breaks and return it will not print 7 and while loop gets false..
+ 1
Hi! try to investigate this problem yourself
Visualize your code execution
(Python, Java, C, C++, JavaScript, Ruby)
https://pythontutor.com
0
I've just got it.It is all because of the condition which is not letting to give anything more than 5.