Skip to content

Instantly share code, notes, and snippets.

@szemate
Last active March 17, 2022 17:55
Show Gist options
  • Save szemate/3622dd5be1fca50415454428698d46b3 to your computer and use it in GitHub Desktop.
Save szemate/3622dd5be1fca50415454428698d46b3 to your computer and use it in GitHub Desktop.
String Comparison Exercise

String Comparison Exercise

In the terminal, run the command node and run the following expressions. What are their outputs? Is there anything you didn't expect?

  • "a" < "b"
  • "A" < "B"
  • "a" < "B"
  • "Alice" < "Bob"
  • "alice" < "Bob"

Characters are compared based on their Unicode numbers (or code points). Take a look at the Unicode Table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment