Listing valid words from phone mapping

Viewed 45

I recently came back from an interview and they asked basically: Given a list of valid words and a mapping of numbers to letters - something like 1 -> ABC, 2->DEF - how would I write a function that returns a list of strings that are valid. I struggled really hard and am looking for guidance.

function validWords(digits, listOfValidWords) {

}

// for example
var dictionary = [//some list of words];
var words = validWords("1456", dictionary)
1 Answers
Related