Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 7x 3x 3x 1x 2x 2x 1x | const alphabetValidator = (alphabet) => {
const illegal = alphabet.match(new RegExp("[\\W_]"));
if (illegal) {
throw new Error(
`Illegal character found in alphabet: ${alphabet.charAt(illegal.index)}`
);
}
const duplicate = alphabet.match(new RegExp("(.+)(?=.*?\\1)", "g"));
if (duplicate) {
throw new Error(`Duplicate character found in alphabet: ${duplicate[0]}`);
}
};
export { alphabetValidator };
|