function extractWordsAndDigits(lines) {
const fMatch = RegExp(words.join("|") + "|\\d");
const rMatch = RegExp(words.map(reverse).join("|") + "|\\d");
const toDigit = (token, regex) => {
const digit = token.match(regex)[0];
return digit.length === 1 ? digit : lookup[digit];
};
return lines.map((s) =>
Number(toDigit(s, fMatch) + toDigit(reverse(s), rMatch))
);
}