Generating Words From Names

Published by Deep Xavier in

Write a function that returns true if a given name can generate an array of words.

Examples

anagram("Tesha Xavier", ["six", "have", "rate"]) ➞ true

anagram("Natalie Portman", ["ornamental", "pita"]) ➞ true

anagram("Chris Pratt", ["chirps", "rat"]) ➞ false
// Not all letters are used 

anagram("Jeff Goldblum", ["jog", "meld", "bluffs"]) ➞ false
// "s" does not exist in the original name

anagram("Justin Bieber", ["injures", "ebb", "it"]) ➞ true

Notes

  • Each letter in the name may only be used once.
  • All letters in the name must be used.
Watch a quick demo on how Edabit works.