Skip to content

Instantly share code, notes, and snippets.

@danielmconrad
Last active June 11, 2020 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielmconrad/d590d6cfd99fef406d0dd2c3e4ada159 to your computer and use it in GitHub Desktop.
Save danielmconrad/d590d6cfd99fef406d0dd2c3e4ada159 to your computer and use it in GitHub Desktop.
Typeahead Challenge

Part 1: A typeahead function

You're given a JSON array of Illinois Cities. With this list, your task is to build out a function that accepts a string and returns back cities that contain the given characters. The function should accept another parameter to limit the amount of matches it returns. The results should be returned in alphabetical order with priority given to matches that start with the characters.

Use your language or framework of choice, and store the data in any fashion you'd like, as long as it's web friendly.

[
  "Summit", "Palatine", "Naperville", "North Chicago", "Springfield", 
  "Arlington Heights", "Oak Park", "Moline", "Calumet City", "Ottawa", 
  "Wood River", "Oregon", "Herrin", "Brookfield", "Kankakee", "Des Plaines", 
  "Cahokia", "Galesburg", "Macomb", "Libertyville", "Effingham", "Petersburg", 
  "Elmhurst", "Aurora", "Danville", "Decatur", "Rockford", "Charleston", 
  "Park Ridge", "Arthur", "Park Forest", "Cicero", "Champaign", "Mount Vernon", 
  "Virden", "Shawneetown", "Kaskaskia", "Cairo", "Chicago Heights", "Carthage",
  "Harrisburg", "Pekin", "Carlinville", "Joliet", "Collinsville", "Galena", 
  "Bloomington", "Granite City", "Normal", "South Holland", "Evanston", 
  "Rantoul", "East Moline", "Glenview", "Lake Forest", "DeKalb", "Belleville", 
  "Waukegan", "Nauvoo", "Quincy", "Wheaton", "Wilmette", "River Forest", 
  "La Salle", "Monmouth", "Kewanee", "Glen Ellyn", "Highland Park", "Centralia", 
  "East Saint Louis", "Skokie", "Dixon", "Mundelein", "Rock Island", "Salem", 
  "Mattoon", "Pontiac", "Belvidere", "Lisle", "Elgin", "Alton", "Urbana", 
  "Lincoln", "Carbondale", "Winnetka", "Chester", "Canton", "Zion", "Chicago", 
  "Streator", "Peoria", "Freeport", "Lombard", "Vandalia", "Jacksonville"
]

Part 2: Tests

Write a unit test that covers the functionality you wrote in part 1.

Part 3: API Endpoint

Turn your function into an api endpoint!

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