Console log problem | SoloLearn: Learn to code for FREE!

+2

Console log problem

Why? https://code.sololearn.com/Wo2a3RZi9E2r/?ref=app

2/20/2020 4:50:38 AM

setu kumar

3 Answers

New Answer

+5

Just adding more to Oma's answer. Strings are compared in lexographical (dictionary) order according to their unicode value. Just an example : compare "abc" and "abd" which one is greater? comparison start at 0th charecter. "a" and "a" both equal, check next charecter. "b" and "b" both equal, check next charecter. "c" and "d" are NOT equal, "d" is certainly greater. therefore "abd" is greater than "abc" You can check utf representation of charecters using codePointAt() method. alert("a".codePointAt(0))

+4

They are not numbers but strings. So we have iexicographical order and not numerical.

+1

Thanks guys Oma Falk 🇮🇳Omkar🕉