0
How does a string compare?
What is the comparison here? And why if Z is replaced by O it turns out 1? And if by L, then 0? var len = 0; for(let ch of "Solo") { if(ch > 'a' && ch < 'z') len++; } console.log(len); //3
4 Answers
+ 2
'S' < 'p' false
'o' < 'p' true
'l' < 'p' true
'o' < 'p' true
+ 1
There checking " solo" are contains alphabets in between a to z.
If you replace z by o, then 'o' < 'o' is false, 's' < 'o' false only 'l' < 'o' true.
same for l
's' < 'l', 'o' < 'l', 'l' < 'l' all false...
+ 1
It was only in the morning that I realized why 'A' large is not in the range from 'a' to 'z' . The key to solving ASCII. Thank you all đ€
0
Thank you, why if you replace Z with P, then you get 3? Doesn't it give out 2?