why got it this result in compare two string? javascript | SoloLearn: Learn to code for FREE!

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?

3/17/2020 5:06:46 AM

MetaCop

3 Answers

New Answer

+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

+1

alert("c">" ") => true because "c" > " "(space)

0

🔫 Rick Grimes thanks!!