Loading...
advanced
Problem 05 • Step 02
Get Hints
Given a masked word and a list of candidate words, filter the list to only those that match the pattern.
getHints(maskedWord, wordList) takes a space-separated masked word (like "a _ _ l e") and an array of words, and returns a new array containing only the words that match the pattern.
Use matchWithGaps (provided as read-only) to check each word.
Rules
- A word matches if
matchWithGaps(maskedWord, word)returnstrue - The result preserves the order of the original word list
- If no words match, return an empty array
Examples
getHints("a _ _ l e", ["apple", "ample", "grape", "apply"])
// ["apple", "ample"]
getHints("_ p _ l e", ["apple", "ample", "angle"])
// ["apple"]
getHints("a _ _ l e", ["grape", "melon"])
// []
Write your tests from scratch. Think about what makes two words distinguishable under a pattern.