Why the if is executing ? Help ! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
23rd Jan 2020, 6:30 AM
Argon
4 Answers
+ 3
if(3<x.length<6){ 3 < 1 -> false (0) 0 < 6 -> true This condition will always be true... If you want to check if the kength is between 3 and 6 do: If ( (3 < x.length) && (x.length < 6) )
23rd Jan 2020, 6:41 AM
unChabon
unChabon - avatar
+ 3
Maybe you want to reformulate your condition like this: if(4<x.length && x.length<6)
23rd Jan 2020, 6:41 AM
Tibor Santa
Tibor Santa - avatar
0
Because the length is less than 6
23rd Jan 2020, 6:38 AM
✳AsterisK✳
✳AsterisK✳ - avatar
0
But the length is also less than 4. and the if condition is greater than 4 and less than 6. then also if is executing !
23rd Jan 2020, 6:40 AM
Argon