+ 3

When you use “<“ doesnt that mean that the value won’t go to 5?

23rd Jul 2019, 10:42 PM
Joan Janku
Joan Janku - avatar
5 Answers
0
In loops it won't go to 5 (1,2,3,4,5), but it will loop 5 times (0,1,2,3,4), and if you use a returning function like this [Javascript sample] : x = 0; function Y(){ if( x < 5 ){ x++; Y(); } else { } } It will go to 5 but when you use this [Javascript sample] : for( i = 1; i < 5; i++ ){ document.write( i ); } It will only go to 4 (1,2,3,4) Edit: assuming you were talking about loops since it was in your tags list
23rd Jul 2019, 11:05 PM
Roel
Roel - avatar
+ 1
Yes, <5 means that if the loop cariable reaches 5 the loop will be exited.
24th Jul 2019, 4:04 AM
Sonic
Sonic - avatar
0
Sir thank you so much for the answer. I appreciate it.
23rd Jul 2019, 11:07 PM
Joan Janku
Joan Janku - avatar
0
No problem
23rd Jul 2019, 11:07 PM
Roel
Roel - avatar
- 1
Yeah, it won't go to 5 and above but can go below than 5 to negative infinity
24th Jul 2019, 3:14 PM
Shukor Ali
Shukor Ali - avatar