Pangrams

  • + 0 comments

    My solution for typescript:

    function pangrams(s: string): string {
        const ALPHABET_LENGTH = 26;
        const IS_PANGRAM = 'pangram';
        const IS_NOT_PANGRAM = 'not pangram'
        
        const isValidChar = (char: string): boolean => char !== ' ';
        
        return new Set(s
            .split('')
            .reduce((acc, char) => {
            return isValidChar(char) ? [...acc, char.toLowerCase()] : acc;
        }, [])).size === ALPHABET_LENGTH ? IS_PANGRAM : IS_NOT_PANGRAM;  
    }