0

why got it this result in compare two string? javascript

console.log("cos" < " year"); // false console.log("cos" < "year"); // true the first lenght 3 of "cos", "year" 4 3<4 ==true 3<5 == true -> be should it why got it the result false?

17th Mar 2020, 5:06 AM
MetaCop
MetaCop - avatar
2 Respostas
+ 3
My guess is it checks each alphabets ASCII value with other Alphabets ASCII. And here, ASCII of space is 32 and ASCII of small c is 99 so obviously 99 is greater than 32
17th Mar 2020, 5:15 AM
Raj Chhatrala
Raj Chhatrala - avatar
17th Mar 2020, 5:25 AM
MetaCop
MetaCop - avatar