const removeFirst = (x, xs, i = xs.indexOf(x)) =>
i < 0
? [... xs]
: [... xs .slice (0, i), ... xs .slice (i + 1)]
const canConstruct = (word, words) =>
word.length == 0
? true
: words .some (
(w) => word .startsWith (w) && canConstruct (word .replace (w, ''), removeFirst(w, words))
)
console .log (canConstruct ("abcdef", ["ab", "abc", "cd", "def", "abcd"])) //=> true
console .log (canConstruct ("abcddc", ["ab", "abc", "cd", "def", "abcd"])) //=> false
console .log (canConstruct ("abcabc", ["ab", "abc", "cd", "def", "abcd"])) //=> false
console .log (canConstruct ("abcabc", ["ab", "abc", "cd", "abc", "def", "abcd"])) //=> true
console .log (canConstruct ("abcabcabc", ["ab", "abc", "cd", "abc", "def", "abcd"])) //=> false