about | help | code help+videos | done | prefs |
firstWord
Given non-empty array of lowercase non-empty strings, return the string that would be first alphabetically. Solve this by looking through the array. NOTE: The compareTo() method of the String class is useful for comparing words alphabetically. "cat".compareTo("dog") is negative because cat is alphabetically before dog. Similarly, "dog".compareTo("cat") is positive. And "cat".compareTo("cat") is 0. firstWord(["cat", "banana", "dog", "tree"]) → "banana" firstWord(["yak", "zebra", "xylophone"]) → "xylophone" firstWord(["man", "many", "mandy", "manana"]) → "man" ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 200
Copyright Nick Parlante 2017 - privacy