Little Dictionary

Published by Helen Yu in

Create a function that takes an initial word and extracts any words that start with the same letters as the initial word.

Examples

dictionary("bu", ["button", "breakfast", "border"]) ➞ ["button"]

dictionary("tri", ["triplet", "tries", "trip", "piano", "tree"]) ➞ ["triplet", "tries", trip"]

dictionary("beau", ["pastry", "delicious", "name", "boring"]) ➞ []

Notes

  • If none of the words match, return an empty list.
  • Keep the filtered list in the same relative order as the original list of words.
Watch a quick demo on how Edabit works.