Advertisement
CoineTre

Pangram - kata

Oct 9th, 2024
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.88 KB | Source Code | 0 0
  1. function isPangram(str) {
  2.   const input = str.replace(/[^\w]/g, '').toLowerCase().split('');
  3.   return [...new Set(input)].length === 26;
  4.  
  5.   }
  6.   console.log(isPangram('Sphinx of black quartz, judge my vow.'));
  7.  
  8. /*A pangram is a sentence that contains every single letter of the alphabet at least once.
  9.  
  10. For example, the sentence 'The quick brown fox jumps over the lazy dog' is a pangram, because it uses the letters A-Z at least once (case is irrelevant).
  11.  
  12. Create a function that accepts a string and detects whether or not it is a pangram. Return true if is a pangram, otherwise, return false.
  13.  
  14. The function should ignore numbers and punctuation.
  15.  
  16. Examples:
  17.  
  18. isPangram('abcdefghijklmnopqrstuvwxyz') === true
  19. isPangram('Sphinx of black quartz, judge my vow.') === true
  20. isPangram('AbCdEfGhIjKlMzxWvUtSrQpOn') === false // 'y' is missing
  21. isPangram('Detect Pangram') === false */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement