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

14th Aug 2020, 8:22 PM
Bomko Aleksey đŸ‘šâ€đŸ’»
Bomko Aleksey đŸ‘šâ€đŸ’» - avatar
4 Answers
+ 2
'S' < 'p' false 'o' < 'p' true 'l' < 'p' true 'o' < 'p' true
14th Aug 2020, 10:54 PM
Artur
Artur - avatar
+ 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...
14th Aug 2020, 8:28 PM
Jayakrishna 🇼🇳
+ 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 đŸ€—
15th Aug 2020, 8:07 AM
Bomko Aleksey đŸ‘šâ€đŸ’»
Bomko Aleksey đŸ‘šâ€đŸ’» - avatar
0
Thank you, why if you replace Z with P, then you get 3? Doesn't it give out 2?
14th Aug 2020, 8:51 PM
Bomko Aleksey đŸ‘šâ€đŸ’»
Bomko Aleksey đŸ‘šâ€đŸ’» - avatar