0

Why the value is 5 ???

I got it from the javascript quiz . I think the answer shuold be multilple numbers not one. I thought it will be the numbers from 2 to 5 function test(number) { while(number < 5) { number++; } return number; } alert(test(2));

19th Aug 2017, 2:39 AM
Abdusamad Abdurashidkhonov
Abdusamad Abdurashidkhonov - avatar
2 Respuestas
+ 2
condition of while loop: number is 2 and 2 is less than 5 so It's true no liar plus number by 1 now number is 3 then exec exec... wait! 5<5 FALSE while loop stop! stop!!! return number;//Number is 5 In short: 5<5 is false Ummm (You should add alert(number) inside while block and then see result for more understanding)
19th Aug 2017, 3:00 AM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
0
aaaa thanks @Very_Hard(java & c++ & c# & py & rust & (AllHard))
19th Aug 2017, 3:14 AM
Abdusamad Abdurashidkhonov
Abdusamad Abdurashidkhonov - avatar