Exercise · Strings · lesson 10 of 12
Exercise: which word comes first
Write a function function isBefore(a, b) that returns true if the word a comes before the word b in alphabetical order, and false otherwise. Capital and small letters count as the same.
isBefore("apple", "Banana")→trueisBefore("Zebra", "apple")→falseisBefore("app", "Apple")→true
Constraints: a and b have 1 to 20 Latin letters; a word that matches the start of another comes before it, and for words that are equal ignoring case the result is false.
Do not add extra imports unless the task says so explicitly.
Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.